mati
<?php

if($_POST['funkcje'] != '')
    showKonkursListAll();

function test()
{
    echo 'test';
}
function VS()
{
    echo "sdsdsa";
    echo "ab";
}
'costam dodam';

$miesiace_nazwy = Array('','stycznia','lutego','marca','kwietnia','maja','czerwca','lipca','sierpnia','września','października','listopada','grudnia');
function ciach($tresc,$ile){ 
    // obliczamy ilość znaków w tekscie 
    $licz = strlen($tresc); 
    // sprawdzamy, czy ilość znaków w tekscie jest większa 
    // lub równa liczbie znaków po jakiej tekst ma być obcięty 
    if ($licz>=$ile) 
    { 
        // obcinamy tekst o określoną ilośc znaków 
        $tnij = substr($tresc,0,$ile); 
        // dodajemy kropeczki (...) 
        $txt = $tnij."(...)"; 
    } 
    else 
    { 
        // jeżeli warunek nie jest spełniony pozostawiamy tekst bez zmian 
        $txt = $tresc; 
    } 
    // zwracamy wynik działania funkcji 
    return $txt; 
} 


function test2()
{
    echo 'test2';
}
function przyjazny_link($string){
	$string = mb_convert_case($string, MB_CASE_LOWER, "UTF-8"); 
	$polskie = array(',',' - ',' ','ę', 'Ę', 'ó', 'Ó', 'Ą', 'ą', 'Ś', 's', 'ł', 'Ł', 'ż', 'Ż', 'Ź', 'ź', 'ć', 'Ć', 'ń', 'Ń','-',"'","/","?", '"', ":", 'ś', '!','.', '&', '&amp;', '#', ';', '[',']','domena.pl', '(', ')', '`', '%', '?', '?', '?',);
	$miedzyn = array('-','-','-','e', 'e', 'o', 'o', 'a', 'a', 's', 's', 'l', 'l', 'z', 'z', 'z', 'z', 'c', 'c', 'n', 'n','-',"","","","","",'s','','', '', '', '', '', '', '', '', '', '', '', '', '',);
	$string = str_replace($polskie, $miedzyn, $string);
	$string = preg_replace('/[^0-9a-z\-]+/', '', $string);
	$string = preg_replace('/[\-]+/', '-', $string);
	$string = trim($string, '_');
	$string = stripslashes($string);
	$string = urlencode($string);
	return $string;
}
function dzisiaj() {
$dzien = date("d");
$miesiac = date("n");
$rok = date("Y");
$dayofweek = date("w");
if ($miesiac == 1) $miesiac = 'stycznia';
if ($miesiac == 2) $miesiac = 'lutego';
if ($miesiac == 3) $miesiac = 'marca';
if ($miesiac == 4) $miesiac = 'kwietnia';
if ($miesiac == 5) $miesiac = 'maja';
if ($miesiac == 6) $miesiac = 'czerwca';
if ($miesiac == 7) $miesiac = 'lipca';
if ($miesiac == 8) $miesiac = 'sierpnia';
if ($miesiac == 9) $miesiac = 'września';
if ($miesiac == 10) $miesiac = 'października';
if ($miesiac == 11) $miesiac = 'listopada';
if ($miesiac == 12) $miesiac = 'grudnia';
if ($dayofweek == "1") $dayofweek = 'poniedziałek';
if ($dayofweek == "2") $dayofweek = 'wtorek';
if ($dayofweek == "3") $dayofweek = 'środa';
if ($dayofweek == "4") $dayofweek = 'czwartek';
if ($dayofweek == "5") $dayofweek = 'piątek';
if ($dayofweek == "6") $dayofweek = 'sobota';
if ($dayofweek == "0") $dayofweek = 'niedziela';
echo $today = $dayofweek.', '.$dzien.' '. $miesiac.' '.$rok;
 echo "<br />";
include_once("Imieniny/imieniny.php3");
}
function dzisiaj_firma() {
$dzien = date("j");
$miesiac = date("n");
$rok = date("Y");
$dayofweek = date("w");
if ($miesiac == 1) $miesiac = 'stycznia';
if ($miesiac == 2) $miesiac = 'lutego';
if ($miesiac == 3) $miesiac = 'marca';
if ($miesiac == 4) $miesiac = 'kwietnia';
if ($miesiac == 5) $miesiac = 'maja';
if ($miesiac == 6) $miesiac = 'czerwca';
if ($miesiac == 7) $miesiac = 'lipca';
if ($miesiac == 8) $miesiac = 'sierpnia';
if ($miesiac == 9) $miesiac = 'września';
if ($miesiac == 10) $miesiac = 'października';
if ($miesiac == 11) $miesiac = 'listopada';
if ($miesiac == 12) $miesiac = 'grudnia';
if ($dayofweek == "1") $dayofweek = 'poniedziałek';
if ($dayofweek == "2") $dayofweek = 'wtorek';
if ($dayofweek == "3") $dayofweek = 'środa';
if ($dayofweek == "4") $dayofweek = 'czwartek';
if ($dayofweek == "5") $dayofweek = 'piątek';
if ($dayofweek == "6") $dayofweek = 'sobota';
if ($dayofweek == "0") $dayofweek = 'niedziela';
echo $today = $dayofweek.', '.$dzien.' '. $miesiac.' '.$rok;
 echo "<br />";
include_once("../../Imieniny/imieniny2.php3");
}
function dzisiaj2() {
$dzien = date("j");
$miesiac = date("n");
$rok = date("Y");
if ($miesiac == 1) $miesiac = 'stycznia';
if ($miesiac == 2) $miesiac = 'lutego';
if ($miesiac == 3) $miesiac = 'marca';
if ($miesiac == 4) $miesiac = 'kwietnia';
if ($miesiac == 5) $miesiac = 'maja';
if ($miesiac == 6) $miesiac = 'czerwca';
if ($miesiac == 7) $miesiac = 'lipca';
if ($miesiac == 8) $miesiac = 'sierpnia';
if ($miesiac == 9) $miesiac = 'września';
if ($miesiac == 10) $miesiac = 'października';
if ($miesiac == 11) $miesiac = 'listopada';
if ($miesiac == 12) $miesiac = 'grudnia';
$today = $dzien.' '. $miesiac.' '.$rok;
return $today;
}
class Flash 
{
	function displayFO($movie, $width, $height) {
	
	$this->movie = $movie;
	$this->width = $width;
	$this->height = $height;
	
	$display = "<object type=\"application/x-shockwave-flash\" data=\"$movie\" width=\"$width\" height=\"$height\">
				<param name=\"movie\" value=\"$movie\" /></object>";
	
	return $display;
	}
	
}
function readZaj($content)
{
    echo "ęymieniemę";
}
function readCatArtName($id)
{
$query = "SELECT nazwa FROM portal_kategorie_artykulow WHERE cat_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	 echo "{$row['nazwa']}";
		} 
}
function readCatArtMenu($cat_zm)
{
$query = "SELECT * FROM portal_kategorie_artykulow";
    $result = mysql_query ($query);
    echo '<h3>';
    while ($row = mysql_fetch_array ($result) ) {
    
	echo "<a href=\"porady.php?cat={$row['cat_id']}\">"; if ($cat_zm == $row['cat_id']) echo "<strong>";readCatArtName($row['cat_id']); if ($cat_zm == $row['cat_id']) echo "</strong>"; echo"</a>&nbsp;&nbsp;|&nbsp;&nbsp;";


		} 
		echo '</h3>';
		
}
function readCatArtMenuTitle($cat_zm)
{
$query = "SELECT * FROM portal_kategorie_artykulow";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	 if ($cat_zm == $row['cat_id']) { readCatArtName($row['cat_id']); } 
		} 
}


function jakas_funkcja()
{

    echo 'cos';
    echo 'tutaj sobie cos dodaje';
    echo 'wypluj sobie jakis tekst. i tu tez.';
    echo 'pod spodem';
}


function displayBanner($klasa)
{
$query = "SELECT * FROM portal_banners where klasa = '$klasa'";
	$result = mysql_query ($query);
	$rows = -1;
	while ($row = mysql_fetch_array ($result)) {
	$rows++;
	}
	$liczba = rand(0, $rows);
	   $query = "SELECT * from portal_banners where klasa = '$klasa'";
	   $lp = 0;
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
     if ($liczba == $lp) {
     
       echo "<a href=\"{$row['link']}\" target=\"_blank\"><img src=\"http://pobieramysie.pl/upload/portal/banners/{$row['miniaturka']}\" alt=\"{$row['miniaturka']}\" border=\"0\"></a>";
       }$lp++;}
}
function showAnkietaAdv($vote, $ank_id)
{
if ($ank_id == '') {
$query = "SELECT * from portal_ankiety ORDER BY data DESC, ank_id DESC LIMIT 1";
       @$result = mysql_query ($query);
	   
       while ($row = mysql_fetch_array ($result)) {
	  
	    $ank_id = $row['ank_id'];
		
		}
}
$cokid = $_COOKIE["pobieramysieplankieta$ank_id"];
if ($vote == '' && $cokid == '') {
$query = "SELECT * from portal_ankiety ORDER BY data DESC, ank_id DESC LIMIT 1";
       @$result = mysql_query ($query);
	   if (mysql_affected_rows() > 0 )
	{
       while ($row = mysql_fetch_array ($result)) {
	  
	    $obecna = $row['ank_id'];
     	$pytanie = $row['pytanie'];
				
		}
		
		echo "<form method=\"post\" action=\"\"><strong>$pytanie</strong><br /><br />
		<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center>
		
		<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">
		";
		$query2 = "SELECT * from portal_odpowiedzi WHERE ank_id = $obecna ORDER BY odp_id ASC";
			@$result2 = mysql_query ($query2);
			while ($row2 = mysql_fetch_array ($result2)) {
			$odpc = $row2['odpowiedz'];
			
			echo "<tr>
			<td valign=\"top\" width=\"10\" align=\"left\"><input name=\"vote\" type=\"radio\" value=\"{$row2['odp_id']}\" id=\"{$row2['odp_id']}\" /></td>
			<td align=\"left\"><label for=\"{$row2['odp_id']}\">$odpc</label></td>
		  </tr>";
			
			
			}
		echo"
		 <tr><td colspan=\"2\">
<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center></td></tr>
		  <tr>
			<td></td>
			<td align=\"left\" width=\"180\"><a href=\"http://pobieramysie.pl/nowa/archiwum_ankiet.php\">archiwum ankiet</a>&nbsp;&nbsp;<input type=\"hidden\" name=\"ank_id\" value=\"$obecna\" /><input type=\"image\" src=\"http://pobieramysie.pl/images/glosuj.gif\" name=\"image\" id=\"go\" /><br /><br /></td>
		  </tr>
		</table>
 
		
		</form>
		";
}
}
if ($vote != '' && $cokid == '') {
// dodanie glosu
?>
<!-- (C) stat24 / Ankieta - glosowanie -->
<script type="text/javascript">
<!--
document.writeln('<'+'scr'+'ipt type="text/javascript" src="http://s4.hit.stat24.com/_'+(new Date()).getTime()+'/script.js?id=nAua1g.K21epRI9P0xePgPU2.ofdOO9yqFqt5Snbc_L.Z7/l=11"></'+'scr'+'ipt>');
//-->
</script>
<?php
$query = "SELECT wynik from portal_odpowiedzi WHERE odp_id  = '$vote'";
$result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	   $zmienna = $row[wynik];
	   $zmienna++;
	   mysql_query("update portal_odpowiedzi SET wynik='$zmienna' WHERE odp_id = '$vote'");
	   }
//prezentacja wyników
$query = "SELECT * from portal_ankiety WHERE ank_id = '$ank_id' LIMIT 1";
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	   
	    $obecna = $row['ank_id'];
     	
		$pytanie = $row['pytanie'];
			$suma = 0;
echo "<strong>$pytanie</strong><br /><br />
		<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center>
	<table width=\"165\" cellspacing=\"2\" cellpadding=\"0\" class=\"wyniki\">
  ";
		
			$query3 = "SELECT wynik  from portal_odpowiedzi WHERE ank_id = '$obecna' ORDER BY odp_id DESC";
			$result3 = mysql_query ($query3);
			while ($row3 = mysql_fetch_array ($result3)) {
			$w = $row3['wynik'];
			$suma = $suma + $w;
		}
			$query2 = "SELECT * from portal_odpowiedzi WHERE ank_id = '$obecna' ORDER BY odp_id ASC";
			$result2 = mysql_query ($query2);
			while ($row2 = mysql_fetch_array ($result2)) {
			$odpc = $row2['odpowiedz'];
			$w = $row2['wynik'];
			$prc = @round(($w / $suma) * 100);
			$pr1c = @ceil((140 * $prc)/100);
			
			echo "<tr>
    <td colspan=\"2\" align=\"left\">$odpc </td>
    </tr>
  <tr>
    <td width=\"140\" align=\"left\"><table border=\"0\" width=\"$pr1c\" cellspacing=\"0\" cellpadding=\"0\" width=\"140\">
  <tr>
    <td height=\"5\" width=\"$pr1c\" bgcolor=\"#CD5D9A\"></td>
  </tr>
</table></td>
    <td width=\"40\">$prc%</td>
    
  </tr>";
			}}
			echo "<tr><td colspan=\"2\">
<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center></td></tr>
		  <tr>
			
			<td align=\"left\" colspan=\"2\"><a href=\"http://pobieramysie.pl/nowa/archiwum_ankiet.php\">archiwum ankiet</a>&nbsp;&nbsp;<input type=\"hidden\" name=\"ank_id\" value=\"$obecna\" /><br /><br /></td>
		  </tr></table>";
}
if ($cokid != '') {
//prezentacja wyników
$query = "SELECT * from portal_ankiety WHERE ank_id = '$cokid' LIMIT 1";
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	   
	    $obecna = $row['ank_id'];
     	
		$pytanie = $row['pytanie'];
			$suma = 0;
echo "<strong>$pytanie</strong><br /><br />
		<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center>
	<table width=\"165\" cellspacing=\"2\" cellpadding=\"0\" class=\"wyniki\">
  ";
		
			$query3 = "SELECT wynik  from portal_odpowiedzi WHERE ank_id = '$obecna'";
			$result3 = mysql_query ($query3);
			while ($row3 = mysql_fetch_array ($result3)) {
			$w = $row3['wynik'];
			$suma = $suma + $w;
		}
			$query2 = "SELECT * from portal_odpowiedzi WHERE ank_id = '$obecna' ORDER BY odp_id ASC";
			$result2 = mysql_query ($query2);
			while ($row2 = mysql_fetch_array ($result2)) {
			$odpc = $row2['odpowiedz'];
			$w = $row2['wynik'];
			$prc = @round(($w / $suma) * 100);
			$pr1c = @ceil((140 * $prc)/100);
			
			echo "<tr>
    <td colspan=\"2\" align=\"left\">$odpc </td>
    </tr>
  <tr>
    <td width=\"140\" align=\"left\"><table border=\"0\" width=\"$pr1c\" cellspacing=\"0\" cellpadding=\"0\" width=\"140\">
  <tr>
    <td height=\"5\" width=\"$pr1c\" bgcolor=\"#CD5D9A\"></td>
  </tr>
</table></td>
    <td width=\"40\">$prc%</td>
    
  </tr>";
			}	}echo "<tr><td colspan=\"2\">
<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center></td></tr>
		  <tr>
			
			<td align=\"left\" width=\"180\" colspan=\"2\"><a href=\"http://pobieramysie.pl/nowa/archiwum_ankiet.php\">archiwum ankiet</a></td>
		  </tr></table>";}	
 echo"
 
  
";
	
}
function showAllAnkietyAdv() {
	
	//prezentacja wyników
/*$query = "SELECT * from portal_ankiety order by data DESC";
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	   
	    $obecna = $row['ank_id'];
     	
		$pytanie = $row['pytanie'];
		$data = $row['data'];
			$suma = 0;
echo "<blockquote><div class=\"ank_all\"><strong>$pytanie</strong>: $data
	<table width=\"180\" cellspacing=\"2\" cellpadding=\"0\" class=\"wyniki\">
  ";
		
			$query3 = "SELECT wynik  from portal_odpowiedzi WHERE ank_id = '$obecna'";
			$result3 = mysql_query ($query3);
			while ($row3 = mysql_fetch_array ($result3)) {
			$w = $row3['wynik'];
			$suma = $suma + $w;
		}
			$query2 = "SELECT * from portal_odpowiedzi WHERE ank_id = '$obecna'";
			$result2 = mysql_query ($query2);
			while ($row2 = mysql_fetch_array ($result2)) {
			$odpc = $row2['odpowiedz'];
			$w = $row2['wynik'];
			$prc = @ceil(($w / $suma) * 100);
			$pr1c = @ceil((180 * $prc)/100);
			
			echo "<tr>
    <td colspan=\"2\" align=\"left\"><font class=\"admin_text\">$odpc </td>
    </tr>
  <tr>
    <td width=\"180\" align=\"left\"><table border=\"0\" width=\"$pr1c\" cellspacing=\"0\" cellpadding=\"0\" width=\"180\">
  <tr>
    <td height=\"5\" width=\"$pr1c\" bgcolor=\"#BC3030\"></td>
  </tr>
</table></td>
    <td width=\"20\"><font class=\"admin_text\">$w</td>
    
  </tr>";
			}
	
		
 echo"
 
  
</table></div></blockquote><br />
<br />
";
}*/
//prezentacja wyników
$query = "SELECT * from portal_ankiety ORDER BY data DESC, ank_id DESC";
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	   
	    $obecna = $row['ank_id'];
     	
		$pytanie = $row['pytanie'];
			$suma = 0;
                            $data = $row['data'];
echo "<h5>$pytanie</h5><h4>$data</h4>
		
	<table width=\"160\" cellspacing=\"2\" cellpadding=\"0\" class=\"wyniki\">
  ";
		
			$query3 = "SELECT wynik  from portal_odpowiedzi WHERE ank_id = '$obecna'";
			$result3 = mysql_query ($query3);
			while ($row3 = mysql_fetch_array ($result3)) {
			$w = $row3['wynik'];
			$suma = $suma + $w;
		}
			$query2 = "SELECT * from portal_odpowiedzi WHERE ank_id = '$obecna' ORDER BY odp_id ASC";
			$result2 = mysql_query ($query2);
			while ($row2 = mysql_fetch_array ($result2)) {
			$odpc = $row2['odpowiedz'];
			$w = $row2['wynik'];
			$prc = @round(($w / $suma) * 100);
			$pr1c = @ceil((140 * $prc)/100);
			
			echo "<tr>
    <td colspan=\"2\" align=\"left\">$odpc </td>
    </tr>
  <tr>
    <td width=\"140\" align=\"left\"><table border=\"0\" width=\"$pr1c\" cellspacing=\"0\" cellpadding=\"0\" width=\"140\">
  <tr>
    <td height=\"5\" width=\"$pr1c\" bgcolor=\"#CD5D9A\"></td>
  </tr>
</table></td>
    <td width=\"40\">$prc %</td>
    
  </tr>";
			}	echo "<tr><td colspan=\"2\">
<center>
		<img src=\"http://pobieramysie.pl/images/ankieta_line.gif\" alt=\"\" />
        </center></td></tr>
		  ";	
 echo"
 
  
</table><br /><br />
";
}}
function getLink($id) {
$query = "SELECT tytul FROM portal_pages where page_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "{$row['tytul']}";
	}
}
function getBody($id) {
$query = "SELECT tresc FROM portal_pages where page_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "{$row['tresc']}";
	}
}

function showGalerie() {
	echo '<div style="float: left; width: 309px; margin-left: 1px;">
		<a href="">
			<img src="images/naglowek_ostatnio_dodane_zdjecia.png" alt="">
		</a>
			<ul id="galeria1">';
	$zapytanie = "SELECT * FROM portal_galerie_zdjecia ORDER BY id DESC LIMIT 20";
	$idzapytania = mysql_query($zapytanie);

	while ($wiersz = mysql_fetch_array($idzapytania)) {   
		$id = $wiersz['id'];
		$gal_id = $wiersz['gal_id'];
		$podpis = $wiersz['podpis'];
		$nazwa = $wiersz['nazwa'];
		$nazwa_zdjecia = explode('.',$nazwa);


		echo '
		<li>
			<a href="/zdjecia_slubne.php?g='.$gal_id.'&z='.$id.'#f"><img style="width: 309px;" src="/upload/portal/galerie/zdjecia/'.$nazwa_zdjecia[0].'_midi_wm.jpg" alt="'.$podpis.'" /></a>
		</li>';

	}
		
	echo '</ul></div>';
	
	
    echo '<div style="float: left; width: 309px; margin-left: 1px;">
		<a href="">
			<img src="images/naglowek_ostatnio_komentowane_zdjecia.png" alt="">
		</a>

	
			<ul id="galeria2">';
	$zapytanie = "SELECT DISTINCT * FROM portal_galerie_komentarze ORDER BY id DESC LIMIT 8";
	$idzapytania = mysql_query($zapytanie);

	while ($wiersz = mysql_fetch_array($idzapytania)) {   
		$zdj_id = $wiersz['zdj_id'];
		$tresc = $wiersz['tresc'];
		$nick = $wiersz['nick'];

		$zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE id='".$zdj_id."'";
		$idzapytania2 = mysql_query($zapytanie2);
		while ($wiersz2 = mysql_fetch_array($idzapytania2)) {   
		  $id = $wiersz2['id'];
		  $gal_id = $wiersz2['gal_id'];
		  $podpis = $wiersz2['podpis'];
		  $nazwa = $wiersz2['nazwa'];
		  $nazwa_zdjecia = explode('.',$nazwa);


		  echo '
		  <li>
			<a href="/zdjecia_slubne.php?g='.$gal_id.'&z='.$zdj_id.'#f"><img style="width: 309px;" src="/upload/portal/galerie/zdjecia/'.$nazwa_zdjecia[0].'_midi_wm.jpg" alt="'.$podpis.'" /></a>
			<div class="rhino-caption"><strong>~ '.$nick.':</strong><br>'.$tresc.'</div>
		  </li>';
		 

		}
	}
	echo '</ul>
	</div>';
		
	
		

	echo '<div style="float: left; width: 309px; height:350px; margin-left: 1px;">
		<a href="">
			<img src="images/naglowek_ostatnio_zaglosowano.png" alt="">
		</a>

	
	<ul id="galeria3">';
	
	$zapytanie = "SELECT * FROM vote ORDER BY date DESC LIMIT 1";
	$idzapytania = mysql_query($zapytanie);

	while ($wiersz = mysql_fetch_array($idzapytania)) {   
		$zdj_id = $wiersz['id'];
		$vote = $wiersz['vote'];
		  
		$zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE id='".$zdj_id."'";
		$idzapytania2 = mysql_query($zapytanie2);
		while ($wiersz2 = mysql_fetch_array($idzapytania2)) {   
			  $id = $wiersz2['id'];
			  $gal_id = $wiersz2['gal_id'];
			  $podpis = $wiersz2['podpis'];
			  $nazwa = $wiersz2['nazwa'];
			  $nazwa_zdjecia = explode('.',$nazwa);
		 
		      echo '<li><p class="tlo_ocena">Ocena<br><span style="font-size:25px;">'.$vote.'/6</span></p>';
			  echo '<a href="/zdjecia_slubne.php?g='.$gal_id.'&z='.$zdj_id.'#f"><img style="width: 309px;" src="/upload/portal/galerie/zdjecia/'.$nazwa_zdjecia[0].'_midi_wm.jpg" alt="'.$podpis.'" /></a></li>';
			 
		  
		}
		 
		  
	}
	echo '</ul>
	</div>';
	
}

function showGalerieKategorie(){
	$zapytanie = "SELECT * FROM portal_galerie_zdjecia";
	$idzapytania = mysql_query($zapytanie);
	$ile_mamy_fotek = mysql_num_rows($idzapytania);  


	echo '<img src="images/cudzyslow.png" style="float:left;"><h2 style="font-size:20px; color:#8f8e8e; line-height:0; margin-left:40px;" class="cufon">Liczba zdjęć to aż '.$ile_mamy_fotek.' - tyle ma tylko PobieramySię!<br /><br />Inspiruj się, komentuj, oceniaj. Zapraszamy!</h2><br />';
	
	$zapytanie4 = "SELECT * FROM portal_galerie_kategorie_glow ORDER BY priorytet DESC";
	$idzapytania4 = mysql_query($zapytanie4);
	while ($wiersz4 = mysql_fetch_array($idzapytania4)) {   
	$kat_glown_id = $wiersz4['id'];
	$nazwa_kat_glow = $wiersz4['nazwa'];
	$miniaturka = $wiersz4['miniaturka'];


	echo '<table><tr><td><p style="margin-left:2px; id="pomoc_'.$kat_glown_id.'"><a href="javascript:rozwin(\'pomoc_'.$kat_glown_id.'\')"><img src="/upload/portal/galerie/'.$miniaturka.'" class="news_img" alt="Kategoria: '.$nazwa.'"></a></p></td></tr></table>';	

	echo '<div class="pomoc_'.$kat_glown_id.'"';
	if($_GET['pomoc']!=$kat_glown_id) echo 'style="display: none;"';
	echo '>';

	echo '<table cellpadding="2"> <tr>';  

	$zapytanie = "SELECT * FROM portal_galerie_kategorie WHERE id_kat_glow = '".$kat_glown_id."' ORDER BY priorytet DESC";
	$idzapytania = mysql_query($zapytanie);
	$i=0;
	while ($wiersz = mysql_fetch_array($idzapytania)) {   
		$kat_id = $wiersz['id'];
		$nazwa = $wiersz['nazwa'];
		$miniaturka = $wiersz['miniaturka'];
		$prio = $wiersz['priorytet'];


		$zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE kat_id_1 ='".$kat_id."' OR
															   kat_id_2 ='".$kat_id."' OR
															   kat_id_3 ='".$kat_id."' OR
															   kat_id_4 ='".$kat_id."' OR
															   kat_id_5 ='".$kat_id."' OR
															   kat_id_6 ='".$kat_id."' OR
															   kat_id_7 ='".$kat_id."' OR
															   kat_id_8 ='".$kat_id."' OR
															   kat_id_9 ='".$kat_id."' OR
															   kat_id_10 ='".$kat_id."'";
		$idzapytania2 = mysql_query($zapytanie2);

		$ile_jest_zdjec = mysql_num_rows($idzapytania2);

		$zapytanie3 = "SELECT * FROM portal_galerie_zdjecia  WHERE kat_id_1 ='".$kat_id."' OR
															   kat_id_2 ='".$kat_id."' OR
															   kat_id_3 ='".$kat_id."' OR
															   kat_id_4 ='".$kat_id."' OR
															   kat_id_5 ='".$kat_id."' OR
															   kat_id_6 ='".$kat_id."' OR
															   kat_id_7 ='".$kat_id."' OR
															   kat_id_8 ='".$kat_id."' OR
															   kat_id_9 ='".$kat_id."' OR
															   kat_id_10 ='".$kat_id."' ORDER BY id DESC LIMIT 1";
		$idzapytania3 = mysql_query($zapytanie3);



		  while ($wiersz3 = mysql_fetch_array($idzapytania3)) {   
			  $pierwsze_zdjecie = $wiersz3['id'];

		   }
		   
		$reszta = $i%3; 
		if ($reszta == 0) echo '</tr><tr>';   

		echo '<td><a href="galeria,'.przyjazny_link($nazwa).','.$kat_id.','.$pierwsze_zdjecie.'.html"><img src="/upload/portal/galerie/'.$miniaturka.'" class="news_img" alt="'.$nazwa.'"></a></td>'; 
		   
		$i++;       
		}
		echo '</tr></table>

		</div>';

	}
}
function showGalerieFirm($ile){
	$zapytanie = "SELECT * FROM portal_galerie ORDER BY data DESC LIMIT ".$ile;
	$idzapytania = mysql_query($zapytanie);

	while ($wiersz = mysql_fetch_array($idzapytania)) {   
		$gal_id = $wiersz['id'];
		$data = $wiersz['data'];
		$tytul = $wiersz['tytul'];
		$miniaturka = $wiersz['miniaturka'];
		$lead = $wiersz['lead'];



		$zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE gal_id ='".$gal_id."'";
		$idzapytania2 = mysql_query($zapytanie2);

		$ile_jest_zdjec = mysql_num_rows($idzapytania2);


		$zapytanie3 = "SELECT * FROM portal_galerie_zdjecia  WHERE gal_id ='".$gal_id."' ORDER BY id DESC LIMIT 1";
		$idzapytania3 = mysql_query($zapytanie3);

		while ($wiersz3 = mysql_fetch_array($idzapytania3)) {   
			$pierwsze_zdjecie = $wiersz3['id'];
		}


		$i++;
		echo '
		<a href="galeriaFirmy,'.przyjazny_link($tytul).','.$gal_id.','.$pierwsze_zdjecie.'.html" style="float:left; width:120px;"><img width="110" src="/upload/portal/galerie/'.$miniaturka.'" class="news_img" alt="'.$tytul.'"></a>
		<p style="float:left; 	width:170px;	font-family:Arial;	font-size:12px;	color:#b5b5b5;">'.$data.'<br />Zdjęć: '.$ile_jest_zdjec.'<br />
		<a href="galeriaFirmy,'.przyjazny_link($tytul).','.$gal_id.','.$pierwsze_zdjecie.'.html">'.$tytul.'</a></p>
		<div style="clear: both;"></div>'; 

	}			


}

function showAktualnosci() {
$query = "SELECT value FROM portal_config WHERE name = 'ile_duzych_newsow'";
$result = mysql_query ($query);
   
while ($row = mysql_fetch_array ($result) ) {
$ile_duzych_newsow = $row['value'];
}
$query = "SELECT value FROM portal_config WHERE name = 'ile_malych_newsow'";
$result = mysql_query ($query);
   
while ($row = mysql_fetch_array ($result) ) {
$ile_malych_newsow = $row['value'];
}
$roznica = $ile_malych_newsow + $ile_duzych_newsow;
$query = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC LIMIT $ile_duzych_newsow";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<table width=\"240\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td><br />
";
	echo "<font class=\"data_newsa\">{$row['data']}</font><br /><a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table class=\"roz1\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><a href=\"show_akt.php?id={$row['news_id']}\"><img src=\"upload/portal/newsy/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"{$row['tytul']}\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}
								echo"{$row['lead']}<a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a><br /><br />";
	 
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
		$lp = 1;
		echo "<strong>Pozostałe:</strong><br />";
		$query = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp > $ile_duzych_newsow && $lp <= $roznica) {
	echo "<a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['lead']}\"><font class=\"tytul_newsa_pozostale\">{$row['tytul']}</font></a><br />";
	}
	$lp++;
		} 
		
		
}
function showAktListBig($xx) {
$query = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC LIMIT $xx";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	echo "<table width=\"475\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td><br />
";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><a href=\"show_akt.php?id={$row['news_id']}\"><img src=\"upload/portal/newsy/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}echo "<font class=\"data_newsa\">{$row['data']}</font><br /><a href=\"show_akt.php?id={$row['news_id']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"show_akt.php?id={$row['news_id']}\">(...)</a><br /><br />
								";
	 
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
				
		
}
function showAktList($xx) {
	$lp = 1;
	$lp2 = 1;
	$query = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp > $xx) {
	if ($lp2 <= 15) {
	echo "<div class=\"news\"><a href=\"show_akt.php?id={$row['news_id']}\">{$row['tytul']}</a></div>";
	
	$lp2 ++;
	}
	}
	$lp++;
		} 
		
		
}
function getAktBody($id) {
$query = "SELECT * FROM portal_newsy where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<font class=\"data_newsa\">{$row['data']}</font><br /><font class=\"tytul_newsa\">{$row['tytul']}</font><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><img src=\"upload/portal/newsy/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"\" class=\"news_img\" /></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}
								echo"{$row['tresc']}<br /><br />";
	}
}
function showPorady() {
	global $miesiace_nazwy;
	$today = date('Y-m-d');
	$lp = 1;
	$query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY data DESC, news_id DESC LIMIT 3";
	//$query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY data DESC, news_id DESC LIMIT 6";
	$result = mysql_query ($query);
	while ($row = mysql_fetch_array ($result) ) {
		$data = explode('-',$row['data']);
		$data = $data[2].' '.$miesiace_nazwy[(int)$data[1]].' '.$data[0];
		echo'<div style="float: left; width: 309px; margin-left: 1px;">
				<a href=""><img src="/upload/portal/porady/'.$row['miniaturka'].'" alt=""></a>
				<h3>'.$row['tytul'].'</h3>
				<div class="data_newsa">'.$data.'</div>
				<p>
					'.ciach(strip_tags($row['lead']),200).'
				</p>
				<a href="porady.php?id='.$row['news_id'].'">+ WIĘCEJ</a>
		</div>';
		 
		$lp ++;
	} 		
}
function showMiasta($wojewodztwo) {
		$parent0 = $_GET['parent0'];
		$parent1 = $_GET['parent1'];
		$parent2 = $_GET['parent2'];
		$parent3 = $_GET['parent3'];
		$parent4 = $_GET['parent4'];
		$cx = $_GET['c'];
if ($wojewodztwo == 9){echo'<div style="clear:both;"></div>';}
if($wojewodztwo>8) $dopisek='_2';
echo'<div class="wojewodztwo'.$dopisek.'">';
echo '<b>';
if ($wojewodztwo == 1) echo'dolnośląskie';
if ($wojewodztwo == 2) echo 'kujawsko-pomorskie';
if ($wojewodztwo == 3) echo 'lubelskie';
if ($wojewodztwo == 4) echo 'lubuskie';
if ($wojewodztwo == 5) echo 'łódzkie';
if ($wojewodztwo == 6) echo 'małopolskie';
if ($wojewodztwo == 7) echo 'mazowieckie';
if ($wojewodztwo == 8) echo 'opolskie';
if ($wojewodztwo == 9) echo 'podkarpackie';
if ($wojewodztwo == 10) echo 'podlaskie';
if ($wojewodztwo == 11) echo 'pomorskie';
if ($wojewodztwo == 12) echo 'śląskie';
if ($wojewodztwo == 13) echo 'świętokrzyskie';
if ($wojewodztwo == 14) echo 'warmińsko-mazurskie';
if ($wojewodztwo == 15) echo 'wielkopolskie';
if ($wojewodztwo == 16) echo 'zachodniopomorskie';
echo '</b><img src="images/menu_tick.png" style="vertical-align:middle; margin: 0 0 0 5px;"><br />';
$pokaz_miasta = array('Warszawa',
'Kraków',
'Łód',
'Wrocław',
'Poznań',
'Gdańsk',
'Szczecin',
'Bydgoszcz',
'Lublin',
'Katowice',
'Białystok',
'Gdynia',
'Częstochowa',
'Radom',
'Sosnowiec',
'Toruń',
'Kielce',
'Gliwice',
'Zabrze',
'Bytom',
'Olsztyn',
'Bielsko-Biała',
'Rzeszów',
'Ruda ląska',
'Rybnik',
'Tychy',
'Dąbrowa Górnicza',
'Płock',
'Elbląg',
'Opole',
'Gorzów Wielkopolski',
'Wałbrzych',
'Włocławek',
'Zielona Góra',
'Tarnów',
'Chorzów',
'Koszalin',
'Kalisz',
'Legnica',
'Grudziądz',
'Słupsk',
'Jaworzno',
'Jastrzębie-Zdrój',
'Jelenia Góra',
'Nowy Sącz',
'Konin',
'Piotrków Trybunalski',
'Siedlce',
'Inowrocław',
'Lubin',
'Mysłowice',
'Piła',
'Ostrowiec więtokrzyski',
'Ostrów Wielkopolski',
'Siemianowice ląskie',
'Stargard Szczeciński',
'Gniezno',
'Suwałki',
'Pabianice',
'Głogów',
'Chełm',
'Zamoć',
'Przemyl',
'Tomaszów Mazowiecki',
'Kędzierzyn-Kole',
'Stalowa Wola',
'Leszno',
'Łomża',
'Żory',
'Bełchatów',
'Mielec',
'Tarnowskie Góry',
'Tczew',
'widnica',
'Piekary ląskie',
'Będzin',
'Zgierz',
'Biała Podlaska',
'Ełk',
'Racibórz',
'Pruszków',
'więtochłowice',
'Ostrołęka',
'Starachowice',
'Zawiercie',
'Legionowo',
'Tarnobrzeg',
'Wodzisław ląski',
'Puławy',
'Skierniewice',
'Radomsko',
'Starogard Gdański',
'Skarżysko-Kamienna',
'Krosno',
'Kutno',
'Dębica',
'Nysa',
'Wejherowo',
'Ciechanów',
'Rumia',
'Kołobrzeg',
'Zduńska Wola',
'Otwock',
'Sieradz',
'Żyrardów',
'winoujcie',
'Owięcim',
'Bolesławiec',
'Piaseczno',
'Jarosław',
'Nowa Sól',
'widnik',
'Chojnice',
'Chrzanów',
'Knurów',
'Sanok',
'Mikołów',
'Sopot',
'Żary',
'Szczecinek',
'Mińsk Mazowiecki',
'Malbork',
'Kwidzyn',
'Sochaczew',
'Brzeg',
'Jasło',
'Olkusz',
'Olenica',
'Wołomin',
'Kranik',
'Cieszyn',
'Czechowice-Dziedzice',
'Lębork',
'Dzierżoniów',
'Police',
'Czelad',
'Nowy Targ',
'Ostróda',
'Myszków',
'Iława',
'Zgorzelec',
'Żywiec',
'Bielawa',
'Oława',
'Łuków',
'Augustów',
'Swarzędz',
'rem',
'Łowicz',
'Bochnia',
'Giżycko',
'Mława',
'Krotoszyn',
'Wrzenia',
'Turek',
'Luboń',
'Gorlice',
'Czerwionka-Leszczyny',
'Kłodzko',
'Kętrzyn',
'Brodnica',
'Grodzisk Mazowiecki',
'Nowy Dwór Mazowiecki',
'Biłgoraj',
'Wyszków',
'Zakopane',
'Żagań',
'Bielsk Podlaski',
'Ząbki',
'Wałcz2',
'Jarocin',
'Pruszcz Gdański');  


$query = "SELECT * FROM portal_tree WHERE parent0 = '0' ORDER BY pri DESC LIMIT 1";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result);

$query2 = "SELECT * FROM portal_miasta WHERE woj_id = '$wojewodztwo' ORDER BY miasto ASC";
$result2 = mysql_query ($query2);
echo'<ul class="lista_miasta">';
$i=1;
while ($row2 = mysql_fetch_array ($result2)) {
	 $miasto = $row2['miasto'];
	 $miasto_id = $row2['miasto_id'];

         if(!$parent0)
                $parent0 = $row['galaz_id'];
         
	// if (in_array($miasto,$pokaz_miasta)) 
         //http://pobieramysie.pl/nowa/katalog,salon-sukien-slubnych,266,269,273,0,0,all,11,20,7,1.html#cattree
	echo '<li><a href="katalog,';
        if (empty($parent1) && !empty($parent0)) {echo przyjazny_link(getTitleCategory2($parent0)); }  
	elseif (!empty($parent1) && empty($parent2)) {echo przyjazny_link(getTitleCategoryBig2($parent1));} 
	elseif (!empty($parent2) && empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent2));}
        elseif (!empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent3));}
        echo ",$parent0,$parent1,$parent2,$parent3,$parent4,all,1,10,$wojewodztwo;$miasto_id.html#cattree\">".$miasto."</a></li>";
	
	$i++;
}
echo'</ul></div>';
}

///
function showGalerie_vertical() {
echo '<div id="slider">
	
        <ul id="sliderContent">	
	    <font class="tytul_newsa">Komentowane zdjęcia:</font><br />';
	$zapytanie = "SELECT * FROM portal_galerie_komentarze ORDER BY RAND() LIMIT 5";
	$idzapytania = mysql_query($zapytanie);

	  while ($wiersz = mysql_fetch_array($idzapytania)) {   
		  $zdj_id = $wiersz['zdj_id'];
		  $tresc = $wiersz['tresc'];
		  $nick = $wiersz['nick'];
		  
		  $zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE id='".$zdj_id."'";
		  $idzapytania2 = mysql_query($zapytanie2);
		  while ($wiersz2 = mysql_fetch_array($idzapytania2)) {   
			  $id = $wiersz2['id'];
			  $gal_id = $wiersz2['gal_id'];
			  $podpis = $wiersz2['podpis'];
			  $nazwa = $wiersz2['nazwa'];
			  $nazwa_zdjecia = explode('.',$nazwa);
		 
		  
			  echo '
			  <li class="sliderImage">
			    <a href="zdjecia_slubn.php?g='.$gal_id.'&z='.$zdj_id.'#f"><img style="width: 238px;" src="upload/portal/galerie/zdjecia/'.$nazwa_zdjecia[0].'_midi_wm.jpg" alt="'.$podpis.'" /></a>
			    <span class="top"><strong>~ '.$nick.':</strong><br>'.$tresc.'</span>
			  </li>';
			 
		  
		  }
		 
		  
		}
		echo '</ul>
		
		</div>
		<br /><br />
		<div>';
	
		

  
	
	$zapytanie = "SELECT * FROM vote ORDER BY RAND() LIMIT 3";
	$idzapytania = mysql_query($zapytanie);

	  while ($wiersz = mysql_fetch_array($idzapytania)) {   
		  $zdj_id = $wiersz['id'];
		  $vote = $wiersz['vote'];
		  
		  $zapytanie2 = "SELECT * FROM portal_galerie_zdjecia WHERE id='".$zdj_id."'";
		  $idzapytania2 = mysql_query($zapytanie2);
		  while ($wiersz2 = mysql_fetch_array($idzapytania2)) {   
			  $id = $wiersz2['id'];
			  $gal_id = $wiersz2['gal_id'];
			  $podpis = $wiersz2['podpis'];
			  $nazwa = $wiersz2['nazwa'];
			  $nazwa_zdjecia = explode('.',$nazwa);
		 
		      echo '<font class="tytul_newsa">Zagłosowano '.$vote.'/6 :</font><br />';
			  echo '<a href="zdjecia_slubne.php?g='.$gal_id.'&z='.$zdj_id.'#f"><img style="width: 224px;" src="upload/portal/galerie/zdjecia/'.$nazwa_zdjecia[0].'_midi_wm.jpg" alt="'.$podpis.'" /></a><br /><br />';
			 
		  
		  }
		 
		  
		}
		echo '</div>';
}		
///
function showPorady_vertical() {
$today = date('Y-m-d');

$i = 1;
//$query = "SELECT * FROM portal_porady ORDER BY data DESC, news_id DESC LIMIT 6";
$query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY RAND() DESC LIMIT 8";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
		 // echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
									  // <tr>
										// <td width=\"84\" height=\"56\"><a href=\"porady.php?id={$row['news_id']}\"><img src=\"upload/portal/porady/min2_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"{$row['tytul']}\" class=\"news_img\" /></a></td>
										// <td width=\"16\"></td>
									  // </tr>
									// </table>";
									// }
									// echo"{$row['lead']}<a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a>";
		if($i==1){
			echo'<a href="porady.php?id='.$row['news_id'].'" class="link_tytul">'.$row['tytul'].'</a> ';
			echo'<a href="porady.php?id='.$row['news_id'].'#komentarze" class="link_komentarze">(komentarze: )</a>';
			echo'<p><img src="/upload/portal/porady/'.$row['miniaturka'].'" style="float:left; margin-right:5px; width:150px;">'.$row['lead'].'</p><hr>';
		}
		else{
			echo'<img style="float:right; margin-top:5px;" src="images/menu_tick.png" onClick="rozwin(\'rozwin_'.$row['news_id'].'\')">';
			echo'<a href="porady.php?id='.$row['news_id'].'" class="link_tytul">'.$row['tytul'].'</a><br>';
			echo'<a href="porady.php?id='.$row['news_id'].'#komentarze" class="link_komentarze">(komentarze: )</a>';
			echo'<p class="rozwin_'.$row['news_id'].'" style="display:none;"><img src="/upload/portal/porady/'.$row['miniaturka'].'" style="float:left; margin-right:5px; width:150px;">'.$row['lead'].'</p><hr>';
		}
		$i++;
	}
}
function showPoradyArchiwum(){
	if($_GET['id'] > 0)
        {
            $z = "SELECT cat, YEAR(data)as rok FROM portal_porady WHERE news_id=".$_GET['id'];
            $idz = mysql_query($z) or die(mysql_error());
            $w0 = mysql_fetch_array($idz);
        }
        
        $z = "SELECT * FROM portal_kategorie_artykulow WHERE cat_id<11 ORDER BY cat_id";
	$idz = mysql_query($z) or die(mysql_error());
	$i=0;
	echo'<hr>';
	while($w = mysql_fetch_array($idz)){
		echo'<a href="javascript:rozwin(\'kat_'.$w['cat_id'].'\');" style="display:inline-block; margin-bottom:5px;">'.mb_strtoupper($w['nazwa'],'UTF-8').'</a> 
                     <a href="porady.php?cat='.$w['cat_id'].'" style="float:right;">[WYBIERZ]</a>';
		echo'<div class="kat_'.$w['cat_id'].'"'; 
                if($w['cat_id'] != $w0['cat']) echo' style="display:none;"'; 
                echo'>';
		$z2 = "SELECT YEAR(data)as rok FROM portal_porady WHERE cat =".$w['cat_id']." GROUP BY rok ORDER BY rok DESC";
		$idz2 = mysql_query($z2) or die(mysql_error());
		$j=0;
		while($w2 = mysql_fetch_array($idz2)){
			echo'<div style="margin-left:10px;">
			<a href="javascript:rozwin(\''.$w['cat_id'].'_'.$w2['rok'].'\');" style="display:block; color:#68C9E5;">'.$w2['rok'].'</a>';
			echo'<div class="' .$w['cat_id'].'_'.$w2['rok'].'"'; 
                        if($w2['rok'] != $w0['rok'] || $w['cat_id'] != $w0['cat']) echo' style="display:none;"'; 
                        echo'>';
			$z3 = "SELECT * FROM portal_porady WHERE cat = ".$w['cat_id']." AND data LIKE '".$w2['rok']."%' ORDER BY data DESC";
			$idz3 = mysql_query($z3) or die(mysql_error());
			while($w3 = mysql_fetch_array($idz3)){
				 $query2 = "SELECT * FROM portal_komentarze WHERE art_id = ".$w3['news_id']." AND potwierdzony = '1'";
				  $result2 = mysql_query ($query2);
				  $ilosc_komentarzy = mysql_num_rows($result2);
				echo'<p style="margin-left:10px; font-size:12px;" class="data_newsa"><a href="porady.php?id='.$w3['news_id'].'" title="'.$w3['tytul'].'" ';
                                if($w3['news_id'] != $_GET['id'])
                                    echo 'style="color:#323232;"';
                                echo '>'.$w3['tytul'].'</a> (komentarze:'.$ilosc_komentarzy.')</p>';
                                 
			}
			echo'</div>
			</div>';
			$j++;
		}		
		echo'</div><hr>';
		$i++;

	}
}
function showArtListBig($xx, $cat) {$today=date('Y-m-d');
if ($cat == '') {$query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY data DESC, news_id DESC LIMIT $xx"; }
else {$query = "SELECT * FROM portal_porady WHERE cat = '$cat' AND data <= '$today' ORDER BY data DESC, news_id DESC LIMIT $xx"; };
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	//echo"<div style=\"clear: both; display: table-row; height: 150px; border-bottom: solid 1px #E3D7DB;\">";
	echo "<table width=\"461\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td>";
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<br />
<table width=\"228\" height=\"152\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"213\" height=\"137\"><a href=\"porady.php?id={$row['news_id']}\"><img src=\"upload/portal/porady/min_{$row['miniaturka']}\" width=\"213\" height=\"137\" alt=\"{$row['tytul']}\" class=\"news_img\" /></a></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}echo "<a title=\"{$row['tytul']}\" href=\"porady.php?id={$row['news_id']}\"><h2>{$row['tytul']}</h2></a><br />";
								echo"{$row['lead']}<a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a>
								";
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
}
function getArtBody($id) {
$query = "SELECT * FROM portal_porady where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<br /><font class=\"data_newsa\">{$row['data']}</font><br /><br /><h1>{$row['tytul']}</h1></font><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
		 echo "
		 <table width=\"228\" height=\"152\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"213\" height=\"137\"><img src=\"upload/portal/porady/min_{$row['miniaturka']}\" width=\"213\" height=\"137\" alt=\"{$row['tytul']}\" class=\"news_img\" /></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}
								echo"{$row['tresc']}<br /><br />";
	}
}
function getArtBody2($id) {
global $miesiace_nazwy;
$query = "SELECT * FROM portal_porady where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	$query2 = "SELECT * FROM portal_komentarze WHERE art_id = '{$row['news_id']}' AND potwierdzony = '1'";
	$result2 = mysql_query ($query2);
	$ilosc_komentarzy = mysql_num_rows($result2);
	
	$data = explode('-',$row['data']);
	$data = $data[2].' '.$miesiace_nazwy[ltrim($data[1],'0')].' '.$data[0];
  // stronicowanie
   $str = $_GET['str'];
   if ($str == '') $str = 1;
   $str2 = $str + 1;
   $liczba_stron = 1;
   $tekst = $row['tresc'];
  if (eregi('NOWASTRONA', $tekst)) {
   
   $liczba_stron = $liczba_stron + substr_count($tekst, 'NOWASTRONA'); 
   }
   
   
   	// echo "<br /><font class=\"data_newsa\">{$row['data']}</font><br /><h1>{$row['tytul']} (".$str."/".$liczba_stron.")</h1></font>";
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '' && ($_GET['str'] == '' || $_GET['str'] == '1')) {
		 // echo "
		 // <table width=\"228\" height=\"152\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  // <tr>
									// <td width=\"213\" height=\"137\"><img src=\"upload/portal/porady/min_{$row['miniaturka']}\" width=\"213\" height=\"137\" alt=\"{$row['tytul']}\" class=\"news_img\" /></td>
									// <td width=\"15\"></td>
								  // </tr>
								// </table>";
		echo'<div><a href="porady.php?id='.$row['news_id'].'" title="'.$row['tytul'].'" style="float:left; margin: 0px 10px 10px 0;"><img src="/upload/portal/porady/min_'.$row['miniaturka'].'"></a>
	<h2 class="cufon"><a href="porady.php?id='.$row['news_id'].'" title="'.$row['tytul'].'" class="cufon" style="font-size:20px; color:#323232;">'.$row['tytul'].'</a></h2>
	<p class="data_newsa">'.$data.' | komentarze: '.$ilosc_komentarzy.'</p>
	</div>';
								
								
	}
								
								
   
   if ($liczba_stron > 1) {
    
	
	if ($str == 1) { $tekst = substr( $tekst , 0 , strpos( $tekst , 'NOWASTRONA2' ) ); }
   	else {
	
	$tekst = substr( $tekst , strpos( $tekst , 'NOWASTRONA'.$str ) );
	if ($str < $liczba_stron)	$tekst = substr( $tekst , 0 , strpos( $tekst , 'NOWASTRONA'.$str2 ) );
	$tekst = ereg_replace('NOWASTRONA'.$str, '', $tekst);
	}
  $tekst = '<p><font face="Verdana" size="2">'.$tekst.'</font></font></p></p>';
   echo $tekst.'<br />'; 
   
   ?>
   
    <script type="text/javascript"><!--
      google_ad_client = "pub-2710687790885824";
      /* 468x60, utworzono 08-12-17 */
      google_ad_slot = "3403014430";
      google_ad_width = 468;
      google_ad_height = 60;
      //-->
      </script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
      </script>
      
      <?
   $next = $str + 1;
   $prev = $str - 1;
   if ($str == 1) $prev = 1;
   if ($str < $liczba_stron)  echo "<p align=\"right\"><a href=\"porady.php?id=".$id."&amp;str=$next\" title=\"Czytaj dalej: ".$row['tytul']."\"><font style=\"color: #5AC1E4; font-weight: bold;\" size=\"3\">czytaj dalej...</font></a></p>";
   
   
   if ($str == 2) echo "<p align=\"center\"><font size=\"2\"><a href=\"porady.php?id=".$id."\" title=\"poprzednia strona ".$row['tytul']."\"><<</a> ";
   else if ($str != 2 && $str != 1) echo "<p align=\"center\"><font size=\"2\"><a href=\"porady.php?id=".$id."&amp;str=$prev\" title=\"poprzednia strona ".$row['tytul']."\"><<</a> ";
   else if ($str == 1) echo "<p align=\"center\"><font size=\"2\">";
   
   for ($i = 1; $i <= $liczba_stron; $i++) {
   
   if ($i == 1) {
          
          if ($i == $str) echo '<font style="color: #5AC1E4; font-weight: bold;" size="4">&nbsp;&nbsp;'.$i.'&nbsp;&nbsp;</font>';
          else echo '<a href="porady.php?id='.$id.'" title="'.$row['tytul'].' strona '.$i.'">&nbsp;&nbsp;'.$i.'&nbsp;&nbsp;</a>';
          
  }
  else {
  
          if ($i == $str) echo '<font style="color:red; font-weight: bold;" size="4">&nbsp;&nbsp;'.$i.'&nbsp;&nbsp;</font>';
          else echo '<a href="porady.php?id='.$id.'&amp;str='.$i.'" title="'.$row['tytul'].' strona '.$i.'">&nbsp;&nbsp;'.$i.'&nbsp;&nbsp;</a>';
  
  }
}
  if ($str < $liczba_stron) echo "<a href=\"porady.php?id=".$id."&amp;str=$next\" title=\"następna strona ".$row['tytul']."\">>></a></font></p>";
  if ($str == $liczba_stron) echo "</font></p>";
  
   } else {
echo $row['tresc'];

   ?>
   <br />
    <script type="text/javascript"><!--
      google_ad_client = "pub-2710687790885824";
      /* 468x60, utworzono 08-12-17 */
      google_ad_slot = "3403014430";
      google_ad_width = 468;
      google_ad_height = 60;
      //-->
      </script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
      </script>
      
      <?
	  
}
								echo"<br />";
	}
}

function confirmArtComment($id) {
	mysql_query("UPDATE portal_komentarze SET potwierdzony= '1' WHERE comment_id= '$id'");
					
	echo "<font color=\"#067109\"><strong><center>Komentarz został POTWIERDZONY!!</center></strong></font><br /><br />";
	
}

function countArtComment($id) {
$query = "SELECT * FROM portal_komentarze WHERE art_id= '$id' AND potwierdzony = '1'";
    $result = mysql_query ($query);
  
    $ilosc_wierszy = mysql_num_rows($result);
   
   
   	
	  if ($ilosc_wierszy == 0) echo '<p align="right">Ten artykuł nie ma jeszcze komentarzy.<br/> Bądź pierwszy - podziel się swoją opinią z innymi!</p>';
    else echo '<strong>A co o tym myślą inni?<br/><br/>Komentarze ('.$ilosc_wierszy.'):</strong><br />';
}
function showArtOpinie($id) {
	$query = "SELECT cat FROM portal_porady WHERE news_id = '$id'";
	$result = mysql_query ($query);
	while ($row = mysql_fetch_array ($result) ) {
		$cat = $row['cat'];
		}

		if (isset($_POST['cadd'])) {
				$tresc = $_POST['tresc'];
				$tresc = ereg_replace("(\r\n|\n|\r)", "<br />", $tresc);
				$autorxx = $_POST['autor'];
				$telefon = $_POST['telefon'];
				$data = date("Y-m-d"); 
				$tn = $_POST['tn'];
				$kod = $_POST['kod'];
				if ($tn == '1') $poprkod="4qw6";
				if ($tn == '2') $poprkod="2ba1";
				if ($tn == '3') $poprkod="9xq7";
				if ($tn == '4') $poprkod="5ys2";
				if ($tn == '5') $poprkod="3gh3";
				if ($kod == $poprkod && $kod != '' && $tn != '') {
				
					if ($cat!=11) { @mysql_query("insert into portal_komentarze (art_id, autor, tresc, data, telefon) VALUES ('$id', '$autorxx', '$tresc', '$data', '$telefon')")  or die ("Could not connect: " . mysql_error());;
					$last_id = mysql_insert_id();
					$komunikat = "<font color=\"#067109\"><strong><center>Dziękujemy za dodanie komentarza!</center></strong></font><br /><br />";
					
					}
					
					else {@mysql_query("insert into portal_komentarze (art_id, autor, tresc, data, telefon, potwierdzony) VALUES ('$id', '$autorxx', '$tresc', '$data', '$telefon', '0')")  or die ("Could not connect: " . mysql_error());;
					$last_id = mysql_insert_id();
					$link = "Aby potwierdzić ten komentarz kliknij tutaj: http://pobieramysie.pl/porady.php?confirm_id=$last_id";
					$alert = "- POTWIERDZ!";
					$komunikat = "<font color=\"#067109\"><strong><center>Dziękujemy za dodanie komentarza!<br /><br />Twój wpis pojawi się na stronie po zaakceptowaniu go przez Administratora</center></strong></font><br /><br />";
					
					}
					
					$query2 = "SELECT tytul FROM portal_porady WHERE news_id = '$id'";
						$result2 = mysql_query ($query2);
						while ($row2 = mysql_fetch_array ($result2) ) {
						$tytul_arta = $row2['tytul'];
						}
					
					///////////////////////////////// WYSYLKA MAILA DO ADMINA ////////////////////////////////////////////
					$email_docelowy = "admin@pobieramysie.pl";
					
					$body = "
	autor: $autorxx
	e-mail: $telefon
	data: $data
	ID komentarza: http://pobieramysie.pl/porady.php?id=$id
	$tresc
					
	$link";
					$tytul = "Dodano nowy komentarz do artykułu: $tytul_arta $alert";
					$naglowki = "From: Pobieramysie.pl <admin@pobieramysie.pl>\r\nReply-To: admin@pobieramysie.pl\r\nContent-type: text/plain; charset=iso-8859-2";
					mail($email_docelowy, $tytul, $body, $naglowki);

						echo $komunikat;
					} 
					else  echo "<font color=\"red\"><strong><center>Niepoprawny kod z obrazka.</center></strong></font><br /><br />";
				  
				  
		}
		///////////////////////////////////////////////////////////////////////////////////////////////////////
		?>
		 <br />
			<?php countArtComment($id);?>
		<br />
			<?php displayCommentBoxArt($id);  
}
function displayCommentBoxArt($id) {
echo "<center><table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">";
$query = "SELECT * FROM portal_komentarze WHERE art_id= '$id' AND potwierdzony = '1'";
    $result = mysql_query ($query);
   while ($row = mysql_fetch_array ($result) ) {
   $autor = $row['autor'];
   $tresc = $row['tresc'];
   $tresc  =wordwrap($tresc, 40, "\n", 1);
   echo "<tr>
    <td class=\"nieparzysta\"><font class=\"data_newsa\">{$row['data']}:</font> <b>$autor</b></td>
  </tr>
  <tr>
    <td class=\"parzysta\"><font size=\"2\">$tresc<br/><br/></font></td>
  </tr>";
}
echo "</table><br />";
?>
<script type="text/javascript">
function validate_form_contact ( )
{
	valid = true;
        if ( document.contact_form.autor.value == "" || document.contact_form.autor.value == "autor" )
        {
 				alert ( "wpisz Autora" );
                valid = false;
        }
		if ( document.contact_form.telefon.value == "" || document.contact_form.telefon.value == "adres e-mail" )
        {
 				alert ( "wpisz adres e-mail" );
                valid = false;
        }  else {
                var x = document.contact_form.telefon.value;
                var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
              if (filter.test(x))  {}
              else {
              alert('niepoprawny adres e-mail');
              valid = false;
                  }
              }
		 
		 
		 if ( document.contact_form.tresc.value == "" ||  document.contact_form.tresc.value == "komentarz" )
        {
 				alert ( "wpisz treść wiadomości" );
                valid = false;
        }  
        return valid;
}</script>
<?php
echo"<form method=\"post\" action=\"?id=$id&amp;p=opinie\" name=\"contact_form\" onSubmit=\"return validate_form_contact ();\">
<input type=\"text\" name=\"autor\"  value=\"autor\" onblur=\"if(this.value=='')this.value='autor';\"  onfocus=\"if(this.value=='autor')this.value='';\" size=\"53\" class=\"text_form\" style=\"width: 350px;\" /><br />
<input type=\"text\" name=\"telefon\"  value=\"adres e-mail\" onblur=\"if(this.value=='')this.value='adres e-mail';\"  onfocus=\"if(this.value=='adres e-mail')this.value='';\" size=\"53\"  class=\"text_form\" style=\"width: 350px;\"/><br />Adres e-mail nie zostanie wyświetlony na stronie, <br />służy jedynie możliwości potwierdzenia komentarza przez administratora strony.<br />
<textarea name=\"tresc\" cols=\"40\" rows=\"8\"onblur=\"if(this.value=='')this.value='komentarz';\"  onfocus=\"if(this.value=='komentarz')this.value='';\" class=\"text_form\" style=\"width: 350px;\">komentarz</textarea><br />";
    generateToken();
    echo"<br />
    
<input name=\"kod\" type=\"text\" value=\"kod z obrazka\" onblur=\"if(this.value=='')this.value='kod z obrazka';\"  onfocus=\"if(this.value=='kod z obrazka')this.value='';\" size=\"10\" class=\"text_form\" style=\"width: 120px;\" /><br /><br />
<input type=\"hidden\" name=\"cadd\" value=\"cadd\"><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"image\" src=\"http://pobieramysie.pl/images/wyslij.jpg\" name=\"image\" id=\"go\">
</form>";
echo "</center><br /><br />";
}
function showArtList($xx, $cat) {$today = date('Y-m-d');
	$lp = 1;
	
	if ($cat == '') $query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY RAND() LIMIT 10"; 
  else $query = "SELECT * FROM portal_porady WHERE cat = '$cat' AND data <= '$today' ORDER BY RAND() LIMIT 5";
  
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
      
      $query2 = "SELECT * FROM portal_komentarze WHERE art_id = '{$row['news_id']}' AND potwierdzony = '1'";
      $result2 = mysql_query ($query2);
      $ilosc_komentarzy = mysql_num_rows($result2);
      
      echo "<div class=\"news\"><a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['lead']}\">{$row['tytul']}</a><br /><font color=\"grey\">Komentarze: $ilosc_komentarzy</font></div>";
	
      $lp++;
		} 
}
function showGazety() {
	
	$query = "SELECT * FROM portal_gazety ORDER BY tytul ASC";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	echo "<div class=\"news\"><a href=\"prasa.php?gazeta={$row['tytul']}\">{$row['tytul']}</a></div>";
	
	
		} 
}
function getPrasaBody($id) {
$query = "SELECT * FROM portal_prasa where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<font class=\"data_newsa\">{$row['data']}</font><br /><font class=\"gazeta\">{$row['gazeta']}</font><br /><font class=\"tytul_newsa\">{$row['tytul']}</font><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"170\" height=\"103\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"88\"><img src=\"upload/portal/prasa/min_{$row['miniaturka']}\" width=\"155\" height=\"88\" alt=\"\" class=\"news_img\" /></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}
								echo"{$row['tresc']}<br /><br />";
	}
}
function showPrasaListBig($xx) {
$query = "SELECT * FROM portal_prasa ORDER BY data DESC, news_id DESC LIMIT $xx";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	echo "<table width=\"461\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td>";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	echo "<br />
<table width=\"170\" height=\"103\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"88\"><a href=\"prasa.php?id={$row['news_id']}\"><img src=\"upload/portal/prasa/min_{$row['miniaturka']}\" width=\"155\" height=\"88\" alt=\"\" class=\"news_img\"  /></a></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}echo "<font class=\"gazeta\">{$row['gazeta']}</font><br /><a href=\"prasa.php?id={$row['news_id']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"prasa.php?id={$row['news_id']}\">(...)</a><br /><br />";
	 
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
				
		
}
function getMatZgazety($gazeta) {
$query = "SELECT * FROM portal_prasa WHERE gazeta = '$gazeta' ORDER BY data DESC, news_id DESC LIMIT 5";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<table width=\"475\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td>";
	
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	echo "<br />
<table width=\"170\" height=\"103\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"88\"><a href=\"prasa.php?id={$row['news_id']}\"><img src=\"upload/portal/prasa/min_{$row['miniaturka']}\" width=\"155\" height=\"88\" alt=\"\" class=\"news_img\"  /></a></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}echo "<font class=\"gazeta\">{$row['gazeta']}</font><br /><a href=\"prasa.php?id={$row['news_id']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"prasa.php?id={$row['news_id']}\">(...)</a><br /><br />";
	 
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
				
		
}
function showPrasaList($gazeta) {
	$query = "SELECT * FROM portal_prasa WHERE gazeta = '$gazeta' ORDER BY data DESC, news_id DESC LIMIT 15";
	
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	echo "<div class=\"news\"><a href=\"prasa.php?id={$row['news_id']}\">{$row['tytul']}</a></div>";
	
	} 
		
		
}

// Nieużywana
function showKonkursListBig() {
	global $miesiace_nazwy;
	$query = "SELECT * FROM portal_konkursy ORDER BY data DESC, news_id DESC LIMIT 6";
    $result = mysql_query ($query); 
	$i=0;
    while ($row = mysql_fetch_array ($result) ) {	
		$miniaturka = $row['miniaturka'];
		if ($miniaturka != '') {
			$data = explode('-',$row['data']);
			$data = $data[2].' '.$miesiace_nazwy[ltrim($data[1],'0')].' '.$data[0];
                        if($i%2==0)echo'<div style="float:left; width:295px; margin-right:15px;">';						
			else echo'<div style="float:left; width:295px;">';						
			echo'<h2 class="cufon"><a href="konkursy.php?id='.$row['news_id'].'" class="cufon" style="font-size:20px; color:#323232;">'.$row['tytul'].'</a></h2>';
			echo'<p class="data_newsa">'.$data.'</p>';
			echo'<a href="konkursy.php?id='.$row['news_id'].'"><img src="/upload/portal/konkursy/'.$row['miniaturka'].'" alt="'.$row['tytul'].'" style="width:295px;"/></a><hr>';
			echo'</div>';
			
			if($i%2==1)echo'<div style="clear:both;"></div>';
			$i++;
		}
	} 
	echo'<br><a href="?min=1&max=10">Pokaż wszystkie &raquo;</a><br>';
		
}
function getKonkursBody($id) {
$query = "SELECT * FROM portal_konkursy where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	echo "<font class=\"data_newsa\">{$row['data']}</font><br /><font class=\"tytul_newsa\">{$row['tytul']}</font><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"170\" height=\"110\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"99\"><img src=\"upload/portal/konkursy/min_{$row['miniaturka']}\" width=\"155\" height=\"99\" alt=\"\" class=\"news_img\" /></td>
									<td width=\"15\"></td>
								  </tr>
								</table>";}
								echo"{$row['tresc']}<br /><br />";
	}
}
function showRabatyListBig() {
$query = "SELECT * FROM firma_rabaty as f, firma_details as d, portal_abonamenty as p WHERE f.user_id = d.user_id AND d.abonament_id = p.abonament_id AND p.rabat = 'tak' ORDER BY data DESC, news_id DESC LIMIT 5";
    $result = mysql_query ($query);
   if (mysql_affected_rows() == 0 )
	{
	
	echo "<br />
<br /><br /><center>:: brak pozycji w wybranej kategorii ::</center>
<br />";
	}
    while ($row = mysql_fetch_array ($result) ) {
	
	$user_fc_id = $row['user_id'];
	$rabacik = $row['tytul'];
	$query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
	
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	$firma = $row2['nazwa'];
	$abid = $row2['abonament_id'];
	$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, rabat, email, skypegg, logo, mapa, godzotw, opinie FROM portal_abonamenty WHERE abonament_id = '$abid'";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
	$wyrozniony = $row7['wyroznienie'];
	$rabat  = $row7['rabat'];
	$email = $row7['email'];
	$www = $row7['www'];
	$skypegg = $row7['skypegg'];
	$logo = $row7['logo'];
	$mapa = $row7['mapa'];
	$godzotw = $row7['godzotw'];
	$opinie = $row7['opinie'];
	}
	$query4 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id'";
	
    $result4 = mysql_query ($query4);
   
    while ($row4 = mysql_fetch_array ($result4) ) {
	$aktywne = $row4['aktywne'];
	
	if ($aktywne != 0) {
	$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
	
    $result3 = mysql_query ($query3);
   
    while ($row3 = mysql_fetch_array ($result3) ) {
	
	$user_log = $row3['user'];
	
	}
	$wizytowka = $row2['wizytowka'];
	
		echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 2px #cb108b; padding:2px;\""; echo">";
	
	echo "<table width=\"470\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"280\" align=\"left\" valign=\"top\">
";
	
	?>
                                <script type="text/javascript" src="http://maps.targeo.pl/bubblemap/bubblemap.php?k=ZjdlYWI5NDZmYTNiNGI5YjhiY2QzMzFjYWM1YWQyMzIxMDE0MWNjMA==&chr=iso-8859-2">
</script>
                              <?php
							   $miasto_do_adres = $row2['miasto'];
								$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
								$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
								$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
								$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
								$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
								$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
								$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
								$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
								$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
								$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
								$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
								$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
								$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
								$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
								$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
								$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
								$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
								$ulica_do_adres = $row2['ulica'];
								$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
								$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
								$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
								$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
								$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
								$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
								$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
								$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
								$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
								$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
								$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
								$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
								$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
								$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
								$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
								$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
								$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
								echo "<a name=\"fr$id\"></a>"; if ($www == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\">"; } echo "<font class=\"tytul_newsa\">$firma</font>"; if ($www == 'tak') { echo "</a>"; } echo "<br />
<br />ul. {$row2['ulica']} {$row2['nrdomu']}<br />{$row2['kod']} {$row2['miasto']}"; if ($mapa == 'tak') { echo "<br />
<a title=\"Firma {$firma} na mapie\" href=\"";
$targeo = $row2['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row2['nrdomu']}"; echo "\">firma na mapie</a>"; } echo " <br /><br />
";
?>
							
<script type="text/javascript">
function myPopup3<? echo $user_fc_id; ?>() {
window.open( "mailer.php?id=<? echo $user_fc_id; ?>", "myWindow", "status = 1, height = 300, width = 600, resizable = 0" )
}
</script>
<?php
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
 ";
								if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $www == 'tak' && $email == 'tak') { echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">E-mail:</font></td>
						";
				echo"										
<td align=\"left\"><a href=\"";
								if ($www == 'tak' && $email == 'tak') {
								echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
								} else {
								
								
								
								
								echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
								
								}
																 echo ">Napisz do nas!</a></td>
															  </tr>";}
								if ($row2['www'] != '' && $www == 'tak') echo " <tr>
																<td align=\"left\" width=\"25\"><font class=\"firma_bold\">WWW:</font> </td>
																<td align=\"left\"> <a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">{$row2['www']}</a></td>
															  </tr>";
															  echo "</table>";
								
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
								if ($row2['telefon'] != '') {
								$telefon = $row2['telefon'];
								$telefon = ereg_replace(",", ",<br>", $telefon);
								
								echo "<tr>
					<td align=\"left\" width=\"50\"><font class=\"firma_bold\">Tel.:</font></td>
					<td align=\"left\" width=\"125\">$telefon</td>
				    </tr>";}
								if ($row2['fax'] != '') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Fax:</font></td>
					<td align=\"left\">{$row2['fax']}</td>
				    </tr>";
								if ($row2['skype'] != '' && $skypegg == 'tak') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Skype:</font></td>
					<td align=\"left\" valign=\"middle\">					
								<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a>";


								if ($row2['gg'] != '' && $skypegg == 'tak') { echo " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"firma_bold\">GG:</font>&nbsp;&nbsp;&nbsp;<a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; } else {echo "<br />";}
								echo "</td>
				    </tr> </table>";
								
								
						echo "</td><td width=\"190\" align=\"right\">	";		
	 echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\" width=\"190\">";
	 if ($wizytowka != ''&& $logo == 'tak') {
								  echo "<tr>
								  <td width=\"10\"></td>
									<td align=\"right\">"; if ($www == 'tak') {  echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\">"; } echo "<img src=\"upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"Logo {$firma}\" class=\"news_img\"  />"; if ($www == 'tak') {  echo"</a>"; } echo "</td>
									
								  </tr>"; } echo "
								  <tr> <td width=\"10\"></td>
								  <td align=\"center\">"; 
								  
								  
								  if ($rabat == 'tak') { 
								$query222 = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
								$result222 = mysql_query ($query222);
							   if (mysql_affected_rows() > 0 )
								{
								while ($row222 = mysql_fetch_array ($result222) ) {
								$rabacik = $row222['tytul'];
								}
								echo "<br />
<br />
<font class=\"rabacik\"><strong>$rabacik</strong></font>";
								}
								}
								  
								  echo "</td></tr>
								</table>";			
								
					echo "</td></tr></table>";	
					
	?>
<script type="text/javascript">
function myPopup2<? echo $user_fc_id; ?>() {
window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
"status = 1, height = 150, width = 300, resizable = 0" )
}
</script>

<?php
								echo "<br /><a href=\"#fr$id\" onclick=\"myPopup2".$user_fc_id."()\"  ><font class=\"gazeta\">dodaj do ulubionych</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; if ($subdomena == 'tak' && $opinie == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=opinie\"><font class=\"gazeta\">zobacz opinie</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } if ($subdomena == 'tak') { echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\"><font class=\"gazeta\">zobacz więcej</font></a>"; } echo "</div>";
								echo"<br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	}}}
}
/*
$query = "SELECT * FROM firma_rabaty ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	$user_r_id = $row['user_id'];
	
	$query2 = "SELECT nazwa  FROM firma_details WHERE user_id = '$user_r_id'";
	
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	$firma = $row2['nazwa'];
	
	} 
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><a href=\"rabaty.php?id={$row['news_id']}\"><img src=\"upload/firma/$user_r_id/rabat/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}echo "<font class=\"data_newsa\">{$row['data']}</font><br /><font class=\"gazeta\">$firma</font><br /><a href=\"rabaty.php?id={$row['news_id']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"rabaty.php?id={$row['news_id']}\">(...)</a><br /><br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	 
	
		} 
	*/			
		
}
function getRabatyBody($id) {
$query = "SELECT * FROM firma_rabaty where news_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	$user_r_id = $row['user_id'];
	
	$query2 = "SELECT nazwa FROM firma_details WHERE user_id = '$user_r_id'";
	
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	$firma = $row2['nazwa'];
	
	} 
	echo "<font class=\"data_newsa\">{$row['data']}</font><br /><font class=\"gazeta\">$firma</font><br /><font class=\"tytul_newsa\">{$row['tytul']}</font><br /><br />";
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"12\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><img src=\"upload/firma/$user_r_id/rabat/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"\" class=\"news_img\" /></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}
								echo"{$row['tresc']}<br /><br />";
	}
}
function showKatalog($parent0, $parent1, $parent2, $parent3, $parent4, $wojewodztwo, $miasto_current) {
$cosjest= false;
$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, rabat, skypegg, logo, mapa, godzotw, opinie FROM portal_abonamenty ORDER BY priorytet DESC";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
	$wyrozniony = $row7['wyroznienie'];
	$rabat  = $row7['rabat'];
	$www = $row7['www'];
	$skypegg = $row7['skypegg'];
	$logo = $row7['logo'];
	$mapa = $row7['mapa'];
	$godzotw = $row7['godzotw'];
	$opinie = $row7['opinie'];
if ($parent0 == 0 && $parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT user_id FROM firma_treeplacement_adv where abonament_id = '$pri' LIMIT 5";
elseif ($parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT user_id  FROM firma_treeplacement_adv where parent0 = '$parent0' AND abonament_id = '$pri' LIMIT 5";
elseif ($parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT user_id  FROM firma_treeplacement_adv where parent0 = '$parent0' AND parent1 = '$parent1' AND abonament_id = '$pri' LIMIT 5";
elseif ($parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT user_id  FROM firma_treeplacement_adv where parent0 = '$parent0' AND parent1 = '$parent1' AND parent2 = '$parent2' AND abonament_id = '$pri' LIMIT 5";
elseif ($parent4 == 0)   
$query = "SELECT DISTINCT user_id  FROM firma_treeplacement_adv where parent0 = '$parent0' AND parent1 = '$parent1' AND parent2 = '$parent2' AND parent3 = '$parent3' AND abonament_id = '$pri' LIMIT 5";
else
$query = "SELECT DISTINCT user_id  FROM firma_treeplacement_adv where parent0 = '$parent0' AND parent1 = '$parent1' AND parent2 = '$parent2' AND parent3 = '$parent3'AND parent4 = '$parent4' AND abonament_id = '$pri' LIMIT 5";
    $result = mysql_query ($query);
   if (mysql_affected_rows() == 0 && $cosjest= false)
	{
	echo "<br />
<br /><br /><center>:: brak pozycji w wybranej kategorii ::</center>
<br />";
	} else {$cosjest= true;}
    while ($row = mysql_fetch_array ($result) ) {
	$user_fc_id = $row['user_id'];
		if ($wojewodztwo != '' && $wojewodztwo != 'dowolne') {
		if ($miasto_current != '' && $miasto_current != 'dowolne') {
			$query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id' AND najbl_miasto = '$miasto_current'";
		} else $query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id' AND woj_id = '$wojewodztwo'";
	}
	else $query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	$firma = $row2['nazwa'];
	$query4 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id'";
    $result4 = mysql_query ($query4);
    while ($row4 = mysql_fetch_array ($result4) ) {
	$aktywne = $row4['aktywne'];
	if ($aktywne != 0) {
	$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
    $result3 = mysql_query ($query3);
    while ($row3 = mysql_fetch_array ($result3) ) {
	$user_log = $row3['user'];
	}
	$wizytowka = $row2['wizytowka'];
	echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 2px #cb108b; padding:2px;\""; echo">";
	echo "<table width=\"470\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"280\" align=\"left\" valign=\"top\">
";
								?>
                                <script type="text/javascript" src="http://maps.targeo.pl/bubblemap/bubblemap.php?k=ZjdlYWI5NDZmYTNiNGI5YjhiY2QzMzFjYWM1YWQyMzIxMDE0MWNjMA==&chr=iso-8859-2">
</script>
                              <?php
							   $miasto_do_adres = $row2['miasto'];
								$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
								$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
								$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
								$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
								$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
								$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
								$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
								$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
								$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
								$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
								$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
								$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
								$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
								$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
								$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
								$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
								$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
								$ulica_do_adres = $row2['ulica'];
								$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
								$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
								$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
								$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
								$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
								$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
								$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
								$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
								$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
								$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
								$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
								$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
								$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
								$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
								$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
								$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
								$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
								echo "<a name=\"fr$id\"></a>"; if ($www == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\">"; } echo "<font class=\"gazeta\">$firma</font>"; if ($www == 'tak') { echo "</a>"; } echo "<br />
<br />ul. {$row2['ulica']} {$row2['nrdomu']}<br />{$row2['kod']} {$row2['miasto']}"; if ($mapa == 'tak') { echo "<br />
<a title=\"Firma {$firma} na mapie\" href=\"";
$targeo = $row2['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row2['nrdomu']}"; echo "\">firma na mapie</a>"; } echo " <br /><br />
";
echo "
<script type=\"text/javascript\">
<!--
function myPopup3() {
window.open( \"mailer.php?id=$user_fc_id\", \"myWindow\", 
\"status = 1, height = 300, width = 600, resizable = 0\" )
}
//-->
</script>
";
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
 ";
								if ($row2['email'] != ''  && $row2['emwid'] == 'tak') echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">E-mail:</font></td>";
			echo"													<td align=\"left\"><a href=\"";
								if ($www == 'tak') {
								echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
								} else {
								echo "#mr$id\" onclick=\"myPopup3()\"  class=\"firma_link\"";
								}
																 echo ">Napisz do nas!</a></td>
															  </tr>";
								if ($row2['www'] != '') echo " <tr>
																<td align=\"left\" width=\"25\"><font class=\"firma_bold\">WWW:</font> </td>
																<td align=\"left\"> <a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">{$row2['www']}</a></td>
															  </tr>";
															  echo "</table>";
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
								if ($row2['telefon'] != '') {
								$telefon = $row2['telefon'];
								$telefon = ereg_replace(",", ",<br>", $telefon);
								echo "<tr>
					<td align=\"left\" width=\"50\"><font class=\"firma_bold\">Tel.:</font></td>
					<td align=\"left\" width=\"125\">$telefon</td>
				    </tr>";}
								if ($row2['fax'] != '') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Fax:</font></td>
					<td align=\"left\">{$row2['fax']}</td>
				    </tr>";
								if ($row2['skype'] != '') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Skype:</font></td>
					<td align=\"left\" valign=\"middle\">					
								<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a>";
								if ($row2['gg'] != '') { echo " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"firma_bold\">GG:</font>&nbsp;&nbsp;&nbsp;<a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; } else {echo "<br />";}
								echo "</td>
				    </tr> </table>";
					echo "</td><td width=\"190\" align=\"right\">	";		
					 echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\" width=\"190\">";
	 if ($wizytowka != ''&& $logo == 'tak') {
								  echo "<tr>
								  <td width=\"10\"></td>
									<td align=\"right\">"; if ($www == 'tak') {  echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\">"; } echo "<img src=\"upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"\" class=\"news_img\" />"; if ($www == 'tak') {  echo"</a>"; } echo "</td>
								  </tr>"; } echo "
								  <tr> <td width=\"10\"></td>
								  <td align=\"center\">"; 
								  if ($rabat == 'tak') { 
								$query = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
								$result = mysql_query ($query);
							   if (mysql_affected_rows() > 0 )
								{
								while ($row = mysql_fetch_array ($result) ) {
								$rabacik = $row['tytul'];
								}
								echo "<br />
<br />
<font class=\"rabacik\"><strong>$rabacik</strong></font>";
								}
								}
								  echo "</td></tr>
								</table>";			
							echo "</td></tr></table>";	
	?>
<script type="text/javascript">
function myPopup2<? echo $user_fc_id; ?>() {
window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
"status = 1, height = 150, width = 300, resizable = 0" )
}
</script>
<?php
									echo "<br /><a href=\"#fr$id\" onclick=\"myPopup2".$user_fc_id."()\"  ><font class=\"tytul_newsa\">dodaj do ulubionych</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; if ($subdomena == 'tak' && $opinie == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=opinie\"><font class=\"gazeta\">zobacz opinie</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } if ($subdomena == 'tak') { echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\"><font class=\"tytul_newsa\">zobacz więcej</font></a>"; } echo "</div>";
								echo"</div><br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	}}
	}
}
}
}
function getCompanyName($id) {
	$query2 = "SELECT nazwa FROM firma_details WHERE user_id = '$id'";
	
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	echo $firma = $row2['nazwa'];
	
	}
	
}
function check_nip($nip)
{
  // tworzenie tablicy wag
  $steps = array(6, 5, 7, 2, 3, 4, 5, 6, 7);
  // wycinanie zbędnych znaków z numeru
  $nip = str_replace('-', '', $nip);
  $nip = str_replace(' ', '', $nip);
   
  if (strlen($nip) != 10) return 0;
  // tworzenie sumy iloczynów
  for ($x = 0; $x < 9; $x++) $sum_nb += $steps[$x] * $nip[$x];
  $sum_m = $sum_nb % 11;
  if ($sum_m == 10) $sum_m = 0; //*
  if ($sum_m == $nip[9]) return 1;
  return 0;
}
function showCompany($id) {
echo "<!-- (C) stat24 / Wizytowki -->
<script type=\"text/javascript\">
<!--
document.writeln('<'+'scr'+'ipt type=\"text/javascript\" src=\"http://s4.hit.stat24.com/_'+(new Date()).getTime()+'/script.js?id=B71FNOsedScY6jZQ6TDO3WXF3y51kuLgiULGNMKmdND.S7/l=11\"></'+'scr'+'ipt>');
//-->
</script>";
	$query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row2 = mysql_fetch_array ($result) ) {
	$firma = $row2['nazwa'];
	
		$query2 = "SELECT * FROM users WHERE user_id = '$id'";
		$result2 = mysql_query ($query2);
		while ($row = mysql_fetch_array ($result2) ) {
		$user = $row['user'];
		
		} 
		echo "<span class=\"tytul_newsa\">$firma</span>";
		$firmId = $row2['user_id'];
		$firmaMiasto = $row2['najbl_miasto'];
		
		$query244 = "SELECT * FROM portal_miasta WHERE miasto = '$firmaMiasto'";
		$result244 = mysql_query ($query244);
		while ($row244 = mysql_fetch_array ($result244)) { $id_miasto_wpisu = $row244['miasto_id']; }
		
		$parent0=$_GET['parent0'];
		$parent1=$_GET['parent1'];
		
		$query_category = "SELECT * FROM firma_treeplacement_adv  WHERE user_id = '$firmId' LIMIT 1";
		$result_category = mysql_query ($query_category);
		
		while ($row_category = mysql_fetch_array ($result_category) ) {
			$IdParent0 = $row_category['parent0'];
	 
			}

		  echo"<p><a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;min=1&amp;max=10&amp;lokacja={$row2['woj_id']}&amp;#cattree\" style='color:#a2a2a2'>";
		if (empty($parent1)) getTitleCategory($parent0);   
		else getTitleCategoryBig($parent1); 
			 
		$wojewodztwo2 = $row2['woj_id'];
		if ($wojewodztwo2 == 1)  echo' dolnośląskie';
		if ($wojewodztwo2 == 2)  echo' kujawsko-pomorskie';
		if ($wojewodztwo2 == 3) echo' lubelskie';
		if ($wojewodztwo2 == 4) echo' lubuskie';
		if ($wojewodztwo2 == 5) echo' łódzkie';
		if ($wojewodztwo2 == 6) echo' małopolskie';
		if ($wojewodztwo2 == 7) echo' mazowieckie';
		if ($wojewodztwo2 == 8) echo' opolskie';
		if ($wojewodztwo2 == 9) echo' podkarpackie';
		if ($wojewodztwo2 == 10) echo' podlaskie';
		if ($wojewodztwo2 == 11) echo' pomorskie';
		if ($wojewodztwo2 == 12) echo' śląskie';
		if ($wojewodztwo2 == 13) echo' świętokrzyskie';
		if ($wojewodztwo2 == 14) echo' warmińsko-mazurskie';
		if ($wojewodztwo2 == 15) echo' wielkopolskie';
		if ($wojewodztwo2 == 16) echo' zachodniopomorskie';
		echo "</a> / <a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;min=1&amp;max=10&amp;lokacja={$row2['woj_id']}&amp; ;$id_miasto_wpisu#cattree\" style='color:#a2a2a2'>";
		if (empty($parent1)) getTitleCategory($parent0);   
		else getTitleCategoryBig($parent1); 
		echo " {$row2['najbl_miasto']}</a></p>";

		
		$rozmiar_zdjecia = getimagesize("../upload/firma/$id/details/{$row2['wizytowka']}");
		if ($rozmiar_zdjecia[1] > 180 ) $zmniejsz_zdjecie = " style='height:180px;'";
		else $zmniejsz_zdjecie = "";               


		
		echo "<p style='float:left; border:1px solid #dadada; margin-right:25px;'><img src=\"/upload/firma/$id/details/{$row2['wizytowka']}\" alt=\"{$firma} [ {$user_log} ] - ";
		if (empty($parent1)) getTitleCategory($parent0); else getTitleCategoryBig($parent1); 
		echo "\" class=\"news_img\"".$zmniejsz_zdjecie."/>"; 
		echo'</p>';
		

		$query66666 = "SELECT * FROM firma_rabaty WHERE user_id = '$id'";
		$result66666 = mysql_query ($query66666);
		$row66666 = mysql_fetch_array($result66666);
		$rabacik = $row66666['tytul'];
		if($rabacik){
		echo'<div style="position:absolute; background: url(images/katalog_rabat_tlo.png) no-repeat top center; width:110px; height:110px; margin-left:530px; margin-top:-10px;">
		<a class="poplight" rel="rabat_'.$user_log.'" href="#?w=400" style="display:block; width:100px; height:100px;"></a>
		</div>';

		echo'<div id="rabat_'.$user_log.'" class="popup_block rec" style="display: none;">
		<a class="close" href="#" onClick="$(\'#rabat_'.$user_log.'\').fadeOut(); return false;"><img class="btn_close" title="Close" src="images/zamknij.png" alt="Close"></a>
		'.$rabacik.'
		</div>';

		}
		
		echo'<table>
			<tr>
				
				<td class="wizytowka_value">';
					if (!empty($row2['ulica'])) echo "ul. ";
					echo "{$row2['ulica']} {$row2['nrdomu']}";
				echo'</td>
			</tr>
			<tr>
				
				<td class="wizytowka_value">';
					echo"{$row2['kod']} {$row2['miasto']}"; 
				echo'</td>
			</tr>
			<tr>
				
				<td class="wizytowka_value">';
					if ($row2['www'] != '' && $www == 'tak') {
						$xtr = $row2['www'];
						if (strlen($xtr) > 32) $xtr = "przejdź na WWW";
						echo"<a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">$xtr</a>";
					}
				echo'</td>
			</tr>
			</table>';
			
		echo'<br><br><table style="float:left;'; if($skypegg == 'tak')echo'border-right: solid 2px '; echo'#e4e4e4; width:180px;">
			<tr>';
				if($row2['telefon']){
					echo'<td class="wizytowka_caption">telefon:</td>
					<td class="wizytowka_value">';
						echo$row2['telefon'];
					echo'</td>';
				}
			echo'</tr>
			<tr>';
				if($row2['fax']){
				echo'<td class="wizytowka_caption">faks:</td>
				<td class="wizytowka_value">';
					echo$row2['fax'];
				echo'</td>';
				}
			echo'</tr>
			<tr>';
					if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $email == 'tak') { 
						echo'<td class="wizytowka_caption">e-mail:</td>
						<td class="wizytowka_value">';
							
								echo'<a href="';
								if ($subdomena == 'tak' && $email == 'tak') {
									echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
								} 
								else {
									echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
								}
								echo ">Napisz do nas!</a></td>
								</tr>";
							
						echo'</td>';
					
					}
			echo'</tr>
			</table>';
		if($skypegg == 'tak'){
			echo'<table style="float:left; width:175px; margin-left:5px;">
				<tr>';
					if ($row2['skype'] != '' && $skypegg == 'tak') {
						echo '<td class="wizytowka_caption">Skype:</td>
						<td class="wizytowka_value">';
											
							echo"<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
							<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
						echo'</td>';
					}
				echo'</tr>
				<tr>';
					if ($row2['gg'] != '' && $skypegg == 'tak') {
						echo'<td class="wizytowka_caption">GG</td>
						<td class="wizytowka_value">';
							 
							echo "<font class=\"firma_bold\"><a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; 
							 
						echo'</td>';
					}
					
				echo'</tr>
				</table>';
		}
		echo'<div style="clear:both; border-bottom:1px dotted #cdcdcd; margin-top:130px;"></div>';
		
		showFrimaOpis($id);
		
		echo'<div style="border-bottom:1px dotted #cdcdcd; margin:30px 0;"></div>
		<div id="map_canvas_0" style="width: 710px; height: 400px;"></div>
		<script type="text/javascript">
		mapa(0,0,0,"'.$row2['ulica'].' '.$row2['nrdomu'].'","'.$row2['kod'].'","'.$row2['miasto'].'","FE7659");
		</script>';
		
		echo'<div style="clear:both; border-bottom:1px dotted #cdcdcd; margin-top:30px;"></div>';
		
		showFrimaOpinie($id);
	
	}
}
function showFrimaOpis($id) {
	mysql_query('SET NAMES utf8');
	mysql_query('SET CHARACTER_SET utf8_unicode_ci');
		$query = "SELECT * FROM firma_wpisy WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
      echo $tresc = iconv("ISO-8859-2","UTF-8",$row['tresc']);
    }
	
		$query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	     $firma = $row['nazwa'];
	     $stronawww = $row['www'];
	  }
	
	if (!empty($tresc) && !empty($stronawww)) echo '<br /><br /><p align="center"><font color=gray>Wybrane fragmenty opisu firmy '.$firma.' mogą pochodzić ze strony <a href="http://'.$stronawww.'" target="_blank">'.$stronawww.'</a><br />Kopiowanie ich bez zgody właściciela firmy jest zabronione może spowodować pociągnięcie do odpowiedzialności cywilnej i karnej.</font></p>';
}
function showFrimaOpinie($id) {

if (isset($_POST['cadd'])) {
$tresc = $_POST['tresc'];
$autorxx = $_POST['autor'];
$telefon = $_POST['telefon'];
$data = date("Y-m-d"); 
$query = "SELECT * FROM firma_details WHERE user_id = '$id'";
	
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	$firma = $row['nazwa'];
	
	}
$tn = $_POST['tn'];
$kod = $_POST['kod'];
if ($tn == '1') $poprkod="4qw6";
if ($tn == '2') $poprkod="2ba1";
if ($tn == '3') $poprkod="9xq7";
if ($tn == '4') $poprkod="5ys2";
if ($tn == '5') $poprkod="3gh3";
if ($kod == $poprkod && $kod != '' && $tn != '') {
@mysql_query("insert into firma_komentarze (user_id, autor, tresc, data, telefon) VALUES ('$id', '$autorxx', '$tresc', '$data', '$telefon')")  or die ("Could not connect: " . mysql_error());;
$kommmig = mysql_insert_id();
$email_docelowy = "admin@pobieramysie.pl";
$body = "autor: $autorxx
telefon: $telefon
data: $data
ID komentarza: $kommmig
$tresc ";
$tytul = "Dodano opinię do: $firma";
$naglowki = "From: Pobieramysie.pl <admin@pobieramysie.pl>\r\nReply-To: admin@pobieramysie.pl\r\nContent-type: text/plain; charset=iso-8859-2";
mail($email_docelowy, $tytul, $body, $naglowki);
  }
  
else { echo '<font color="red">Komentarz <b>NIE został dodany</b>. Niepoprawny kod z obrazka.</font>';}
}
displayCommentBox($id);
 // <br />
	// <br /><strong>komentarze (php countComment($id);):</strong> <br />
// <br />
 
}
function showFrimaKontakt($id) {
// zapis informacji o wyświetleniu w katalogu
	$query555 = "SELECT * FROM mail_counter WHERE user_id = '$id' ";
       $result555 = mysql_query ($query555);
	   if (mysql_affected_rows() == 0) {
	   //insert
	   mysql_query("insert into mail_counter (user_id, counter) VALUES ('$id', 1)");
	   } else {
       while ($row555 = mysql_fetch_array ($result555)) {
	   
	   $counter = $row555['counter'];
	   $counter++;
	   }
		mysql_query("update mail_counter SET counter= '$counter' WHERE user_id= '$id'");
	   }
	
	if (isset($_POST['form_sent'])) {
	$imie = $_POST['imie'];
$email = $_POST['email'];
$telefon = $_POST['telefon'];
$tresc = $_POST['tresc'];
$tn = $_POST['tn'];
$kod = $_POST['kod'];
if ($tn == '1') $poprkod="4qw6";
if ($tn == '2') $poprkod="2ba1";
if ($tn == '3') $poprkod="9xq7";
if ($tn == '4') $poprkod="5ys2";
if ($tn == '5') $poprkod="3gh3";
if ($kod == $poprkod) {
		   //$email_docelowy = "admin@pobieramysie.pl";
$body = "od: $imie
email: $email
telefon: $telefon
$tresc ";
	//echo "<strong>Twój formularz został wysłany. </strong>";
$query = "SELECT  f.email, f.nazwa FROM firma_details as f, users as u WHERE u.user_id = '$id' AND u.user_id = f.user_id";
	
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	$email_docelowy = $row['email'];
	$nazwa = $row['nazwa'];
	}
	$tytul = "Zapytanie od użytkownika portalu PobieramySie.pl";
	$naglowki = "From: Pobieramysie.pl <admin@pobieramysie.pl>\r\nReply-To: $email\r\nContent-type: text/plain; charset=iso-8859-2";
	mail($email_docelowy, $tytul, $body, $naglowki);
	mail("admin@pobieramysie.pl", "Firma (".$nazwa.") otrzymała zapytanie z subdomeny", $body, $naglowki);
	$today = date("Y-m-d"); 
	echo "<strong>Twój e-mail został wysłany. </strong>";
	@mysql_query("insert into firma_emaile (user_id, autor, tresc, data, telefon) VALUES ('$id', '$imie', '$tresc', '$today', '$telefon')")  or die ("Could not connect: " . mysql_error());;
	} else { echo "<strong>Wpisałeś niepoprawny pin. </strong>"; }
	} else {
	// obsluga odbioru tresci z formularza
		$query = "SELECT email, telefon, emwid FROM firma_details WHERE user_id = '$id'";
	
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	
	$email = $row['email'];
	$emwid = $row['emwid'];
	$telefon = $row['telefon'];
	}
	if ($email == ''  || $emwid == 'nie') {
	$telefon = ereg_replace(",", "<!-- ", $telefon);
	//$telefon = $telefon." -->";
	echo "<font size=\"+1\">Zapraszamy do kontaktu telefonicznego z naszą firmą pod numerem telefonu:<br />
 $telefon</font>";
	} else {
	?><br />
<br />
<center>        <strong> Aby skontaktować się z wybraną firmą wypełnij poniższy formularz: </strong><br />
<br />
<script type="text/javascript">
function validate_form_contact ( )
{
	valid = true;
        if ( document.contact_form.imie.value == "" )
        {
 				alert ( "wpisz Imię i Nazwisko" );
                valid = false;
        }
		if ( document.contact_form.email.value == "" )
        {
 				alert ( "wpisz adres e-mail" );
                valid = false;
        }
		 if ( document.contact_form.tresc.value == "" )
        {
 				alert ( "wpisz treść wiadomości" );
                valid = false;
        }
		
        
        return valid;
}</script>
   <form method="post" action="index.php?p=kontakt" name="contact_form" onSubmit="return validate_form_contact ();">
   
   <table width="427" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left">Imię i Nazwisko</td>
    <td colspan="2" align="left"><input name="imie" type="text" size="30" /></td>
    </tr>
  <tr>
    <td align="left">Twój e-mail</td>
    <td colspan="2" align="left"><input name="email" type="text" size="30" /></td>
    </tr>
  <tr>
    <td align="left">Numer telefonu</td>
    <td colspan="2" align="left"><input name="telefon" type="text" size="30" /></td>
    </tr>
  <tr>
    <td align="left">Treść wiadomości</td>
    <td colspan="2" align="left"><textarea name="tresc" cols="32" rows="8"></textarea></td>
    </tr>
  <tr>
    <td align="left"> Kod z obrazka</td>
    <td align="left"> <input name="kod" type="text" size="10" /> </td>
    <td align="left"><?php
    generateToken();
	?>  <input type="hidden" name="form_sent" value="1" /><input type="image" src="http://pobieramysie.pl/images/wyslij.jpg" name="image" id="go" /></td>
  </tr>
</table>
   </form>
   </center>
    <?php }}
}
function showFirmaGal ($id, $pic_id) {
$gal_id = $_GET['gal'];
	$query = "SELECT * FROM firma_galeries WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
		$gal_id = $row['gal_id'];
		echo'<ul id="galeriafirmy" class="jcarousel-skin-tango">';
		$query3 = "SELECT * FROM  firma_gp WHERE gal_id = '$gal_id' ORDER BY pic_id ASC";
		$result3 = mysql_query ($query3);
		while ($row3 = mysql_fetch_array ($result3) ) {

			echo "<li><a href=\"index.php?gal=$gal_id&amp;pic_id={$row3['pic_id']}&amp;p=galeria#subcontent\"><img src=\"http://pobieramysie.pl/upload/firma/$id/galeries/min2_{$row3['miniaturka']}\" alt=\"{$row3['podpis']}\" border=\"0\" class=\"gal\" ></a></li>";
		}
		echo'</ul>';
	}
}
function search($words, $sf, $sp, $sa) {
$x1 = 0;
if ($sf == 1) {
		//zapisanie stringa do bazy
		@mysql_query("insert into portal_szukane_frazy (fraza) VALUES ('$words')")  or die ("Could not connect: " . mysql_error());;
		
		// wyszukiwanie firm
		
		if (!isset($_GET['pokaz'])) {
		
		$limit =  "LIMIT 15";
		
		} else {
		
		$limit =  "LIMIT 30";
		
			}
		
			$word = explode(' ',$words);
				
				$additionalSQL = '';
				foreach ($word as $w)
					$additionalSQL .= " AND CONCAT(f.nazwa, f.miasto, f.klucz, u.user) LIKE '%$w%' ";
				   
				$query = "SELECT f.user_id, f.nazwa, f.miasto, f.www, f.wizytowka, f.klucz, f.abonament_id 
				FROM firma_details as f, users as u, firma_platnosci fp, portal_abonamenty pa
				WHERE fp.aktywne!=0
				AND (f.user_id = u.user_id)
				AND (f.user_id = fp.user_id)
				AND (fp.abonament_id  = pa.abonament_id)
				
				$additionalSQL
					
				ORDER BY pa.priorytet DESC, f.nazwa ASC
				
						$limit
				
				";
		
			$result = mysql_query ($query);
			$ile_wynikow = mysql_affected_rows();
		
			 if (mysql_affected_rows() > 0 )
		
			{
		
			$x1 = 1;
		
			echo "<br />
		
		<br /><div class=\"search_box\"> Wyniki wśród firm: </div><br />
		
		<br />";
		
			}
		
		   
		
			while ($row = mysql_fetch_array ($result) ) 
			{
		
			
			
				$firma = $row['nazwa'];
			
				$user_fc_id = $row['user_id'];
			
				$abonament_id = $row['abonament_id'];
				
				$aktywne = $row['aktywne'];	
	
							
								$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, rabat, email, skypegg, logo, mapa, godzotw, subdomena, opinie FROM portal_abonamenty WHERE abonament_id = '$abonament_id'";
			
				$result7 = mysql_query($query7);
			
				 while ($row7 = mysql_fetch_array ($result7) ) 
				 {      
			
					$pri = $row7['abonament_id'];				
					$wyrozniony = $row7['wyroznienie'];				
					$rabat  = $row7['rabat'];				
					$email = $row7['email'];				
					$www = $row7['www'];				
					$skypegg = $row7['skypegg'];				
					$logo = $row7['logo'];
					$mapa = $row7['mapa'];				
					$godzotw = $row7['godzotw'];				
					$subdomena = $row7['subdomena'];				
					$opinie = $row7['opinie'];
		
				}
											
		
			$query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
			$result2 = mysql_query ($query2);   
		
			while ($row2 = mysql_fetch_array ($result2) ) 
			{
				
					$firma = $row2['nazwa'];
			
								
						
				
							
									$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
								
									$result3 = mysql_query ($query3);
								
									while ($row3 = mysql_fetch_array ($result3) ) {
										$user_log = $row3['user'];
								}
						
							$wizytowka = $row2['wizytowka'];
						
								echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 2px #cb108b; padding:2px;\""; echo">";
						
									
								
									echo "<table width=\"470\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
								
								  <tr>
								
									<td width=\"470\" colspan=\"2\" align=\"left\" valign=\"top\">
								
								";
						
							
						
							
						
														?>
						
														<script type="text/javascript" src="http://maps.targeo.pl/bubblemap/bubblemap.php?k=ZjdlYWI5NDZmYTNiNGI5YjhiY2QzMzFjYWM1YWQyMzIxMDE0MWNjMA==&chr=iso-8859-2">
						
														</script>
						
														<?php
						
														$miasto_do_adres = $row2['miasto'];
						
														$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
						
														$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
						
														$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
						
														$ulica_do_adres = $row2['ulica'];
						
														$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
						
														$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
						
														$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
						
														if ($subdomena == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<font class=\"tytul_newsa\">$firma</font>"; if ($subdomena == 'tak') { echo "</a>"; } echo "
						
						</td></tr><tr>
						
							<td width=\"380\" align=\"left\" valign=\"top\"><br />"; if (!empty($row2['ulica'])) echo "ul. "; echo "{$row2['ulica']} {$row2['nrdomu']}<br />{$row2['kod']} {$row2['miasto']}<br />";
						
						if ($mapa == 'tak') { echo"
						
						<a title=\"Firma {$firma} na mapie\" href=\"";
						
						$targeo = $row2['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row2['nrdomu']}"; echo "\">firma na mapie</a><br />"; } echo"<br />
						
						";
						
						?>
						
													
						
						<script type="text/javascript">
						
						function myPopup3<? echo $user_fc_id; ?>() {
						
						window.open( "mailer.php?id=<? echo $user_fc_id; ?>", "myWindow", "status = 1, height = 300, width = 600, resizable = 0" )
						
						}
						
						</script>
						
						<?php
						
														echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
						
						 ";
						
														if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $email == 'tak')  { echo " <tr>
						
																						<td align=\"left\" width=\"50\"><font class=\"firma_bold\">E-mail:</font></td>"; echo"
						
																						<td align=\"left\"><a href=\"";
						
														if ($subdomena  == 'tak' && $email == 'tak') {
						
														echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
						
														} else {
						
														echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
						
														}
						
																						 echo ">Napisz do nas!</a></td>
						
																					  </tr>"; }
						
														if ($row2['www'] != '' && $www == 'tak') {
						
														$xtr = $row2['www'];
						
														if (strlen($xtr) > 32) $xtr = "przejdź na WWW";
						
														echo " <tr>
						
																						<td align=\"left\" width=\"50\"><font class=\"firma_bold\">WWW: </font> </td>
						
																						<td align=\"left\"><a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">$xtr</a></td>
						
																					  </tr>";
						
																					  }
						
																					  echo "</table>";
						
														
						
														echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
						
														if ($row2['telefon'] != '') {
						
														$telefon = $row2['telefon'];
						
														$telefon = ereg_replace(",", ",<br>", $telefon);
						
														
						
														echo "<tr>
						
											<td align=\"left\" width=\"50\"><font class=\"firma_bold\">Tel.:</font></td>
						
											<td align=\"left\" width=\"125\">$telefon</td>
						
											</tr>";}
						
														if ($row2['fax'] != '') echo "<tr>
						
											<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Fax:</font></td>
						
											<td align=\"left\">{$row2['fax']}</td>
						
											</tr>";
						
														if ($row2['skype'] != '' && $skypegg == 'tak') echo "<tr>
						
											<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Skype:</font></td>
						
											<td align=\"left\" valign=\"middle\">					
						
														<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
						
						<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a>";
						
														if ($row2['gg'] != '' && $skypegg == 'tak') { echo " <font class=\"firma_bold\">GG:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; } else {echo "<br />";}
						
														echo "</td>
						
											</tr> </table>";
						
														
						
														
						
										echo "</td><td width=\"190\" align=\"right\">	";		
						
							echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\">";
						
							 if ($wizytowka != ''&& $logo == 'tak') {
							 
							 $rozmiar_zdjecia = getimagesize("upload/firma/$user_fc_id/details/{$row2['wizytowka']}");
							 if ($rozmiar_zdjecia[1] > 180 ) $zmniejsz_zdjecie = " height=\"180\"";
							 else $zmniejsz_zdjecie = "";
						
														  echo "<tr>
						
														  <td width=\"10\"></td>
						
															<td align=\"right\">"; if ($subdomena == 'tak') {  echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<img src=\"upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"Logo {$firma}\" class=\"news_img\"".$zmniejsz_zdjecie."/>"; if ($subdomena == 'tak') {  echo"</a>"; } echo "</td>
						
															
						
														  </tr>"; } echo "
						
														  <tr> <td width=\"10\"></td>
						
														  <td align=\"center\">"; 
						
														  if ($rabat == 'tak') { 
						
														$query = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
						
						
						
														$result88 = mysql_query ($query);
						
													   if (mysql_affected_rows() > 0 )
						
														{
						
														while ($row = mysql_fetch_array ($result88) ) {
						
														$rabacik = $row['tytul'];
						
														}
						
														echo "<br />
						
						<br />
						
						<font class=\"rabacik\"><strong>$rabacik</strong></font>";
						
														}
						
														}
						
														  
						
														  echo "</td></tr>
						
														</table>";			
						
													echo "</td></tr></table>";	
						
														
						
								?>
						
						<script type="text/javascript">
						
						function myPopup2<? echo $user_fc_id; ?>() {
						
						window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
						
						"status = 1, height = 150, width = 300, resizable = 0" )
						
						}
						
						</script>
						
						
						
						
						
						<?php
						
														echo "<br /><a href=\"#fr$id\" onclick=\"myPopup2".$user_fc_id."()\"  ><font class=\"gazeta\">dodaj do ulubionych</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; if ($subdomena == 'tak' && $opinie == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=opinie\"><font class=\"gazeta\">zobacz opinie</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } if ($subdomena == 'tak') { echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\"><font class=\"gazeta\">zobacz więcej</font></a>"; } 
						
														echo"</div><br /><br />
						
														<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
						
							
			}
		
			}
if (!isset($_GET['pokaz']) && $ile_wynikow >= 15) {
echo "<br />
<center>
<p>To tylko wyszukanych <b>15 firm</b>.<br />Sprecyzuj frazę wyszukiwania lub <a href=\"search.php?words=$words&amp;sf=1&amp;sp=0&amp;sa=0&amp;pokaz=wszystkie\">pokaż więcej firm</a> (max 30)</p>
</center>";
}		
		
}
if ($sp == 1) {
// wyszukiwanie par
/*
if (!isset($_GET['pokaz'])) {
$query = "SELECT * FROM para_details as f, users as u WHERE (f.user_id = u.user_id) AND (f.imie_panna  LIKE '%$words%' OR f.nazwisko_panna  LIKE '%$words%' OR f.imie_pan  LIKE '%$words%' OR f.nazwisko_pan   LIKE '%$words%' OR f.miasto LIKE '%$words%' OR u.user LIKE '%$words%') LIMIT 5"; 
} else {
	$query = "SELECT * FROM para_details as f, users as u WHERE (f.user_id = u.user_id) AND (f.imie_panna  LIKE '%$words%' OR f.nazwisko_panna  LIKE '%$words%' OR f.imie_pan  LIKE '%$words%' OR f.nazwisko_pan   LIKE '%$words%' OR f.miasto LIKE '%$words%' OR u.user LIKE '%$words%')"; 
	
	}
    $result = mysql_query ($query);
*/
if (!isset($_GET['pokaz'])) {
		
		$limit =  "LIMIT 5";
		
		} else {
		
		$limit =  "";
		
			}
		
			$word = explode(' ',$words);
				
				$additionalSQL = '';
				foreach ($word as $w)
					$additionalSQL .= " AND CONCAT(pd.imie_panna, pd.nazwisko_panna, pd.imie_pan, pd.nazwisko_pan, pd.email, pd.miasto, u.user) LIKE '%$w%' ";
				   
				$query = "SELECT *
				FROM para_details as pd, users as u
				WHERE (pd.user_id = u.user_id)
				
				$additionalSQL
				
				ORDER BY u.user_id DESC
					
	
						$limit
				
				";
				
		$result = mysql_query ($query);		
   if (mysql_affected_rows() > 0 )
	{
	$x1 = 1;
	echo "<br />
<br /><div class=\"search_box\"> Wyniki wśród par: </div><br />
<br />";
	}
    while ($row = mysql_fetch_array ($result) ) {
	
	$user_xxxx_id = $row['user_id'];
	$query3 = "SELECT user FROM users where user_id = '$user_xxxx_id'";
    $result3 = mysql_query ($query3);
   
    while ($row3 = mysql_fetch_array ($result3) ) {
	$userlog3 = $row3['user'];
	
	}
	$wizytowka = $row['wizytowka'];
	echo "<div class=\"res_box\">";
	if ($wizytowka != '') {
	 echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td ><a href=\"http://$userlog3.pobieramysie.pl\" target=\"_blank\"><img src=\"./upload/para/$user_xxxx_id/details/min_{$row['wizytowka']}\"  alt=\"\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}
								echo "<a href=\"http://$userlog3.pobieramysie.pl\" target=\"_blank\"><font class=\"tytul_newsa\">{$row['imie_panna']} i {$row['imie_pan']}</font></a><br /><br />";
								echo"{$row['miasto']}<br /><br /><br /><br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	 
	echo "</div>";
		} 
}
if ($sa == 1) {
// wyszukiwanie artykułów
/*
if (!isset($_GET['pokaz'])) {
$query = "SELECT * FROM portal_porady WHERE 
(tytul LIKE '%$word_1%' OR lead  LIKE '%$word_1%' OR tresc LIKE '%$word_1%') AND
(tytul LIKE '%$word_2%' OR lead  LIKE '%$word_2%' OR tresc LIKE '%$word_2%') AND
(tytul LIKE '%$word_3%' OR lead  LIKE '%$word_3%' OR tresc LIKE '%$word_3%')
LIMIT 5";  
} else {
$query = "SELECT * FROM portal_porady WHERE 
(tytul LIKE '%$word_1%' OR lead  LIKE '%$word_1%' OR tresc LIKE '%$word_1%') AND
(tytul LIKE '%$word_2%' OR lead  LIKE '%$word_2%' OR tresc LIKE '%$word_2%') AND
(tytul LIKE '%$word_3%' OR lead  LIKE '%$word_3%' OR tresc LIKE '%$word_3%')";  
	}
    $result = mysql_query ($query);
*/
	if (!isset($_GET['pokaz'])) {
		
		$limit =  "LIMIT 5";
		
		} else {
		
		$limit =  "";
		
			}
		
			$word = explode(' ',$words);
				
				$additionalSQL = '';
				foreach ($word as $key => $w)
					if ($key == 0) $additionalSQL .= " CONCAT(pp.tytul, pp.lead, pp.tresc) LIKE '%$w%' ";
					else $additionalSQL .= " AND CONCAT(pp.tytul, pp.lead, pp.tresc) LIKE '%$w%' ";
				   
				$query = "SELECT *
				FROM portal_porady as pp
				WHERE
				
				$additionalSQL
					
				ORDER BY pp.tytul
				
						$limit
				
				";
		
			$result = mysql_query ($query);
			
			
   if (mysql_affected_rows() > 0 )
	{
	$x1 = 1;
	echo "<br />
<br /><div class=\"search_box\"> Wyniki wśród artykułów:</div><br />
<br />";
	}
    while ($row = mysql_fetch_array ($result) ) {
	
	
	
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><a href=\"porady.php?id={$row['news_id']}\"><img src=\"upload/portal/porady/"; 
									$test = file_exists("upload/portal/porady/min2_".$miniaturka);
									if (!$test) echo "min_";
									else echo "min2_";
									
									echo "{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}echo "<a href=\"porady.php?id={$row['news_id']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"porady.php?id={$row['news_id']}\"><img src=\"images/bmarrow2.gif\" alt=\"\" border=\"0\" /></a><br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	 
	
		} 
}
if ($x1 == 0) {
echo "<center><strong>Nie znaleziono wyników odpowiadających Twojemu zapytaniu. <br />
						Spróbuj zmienić słowa kluczowe.</strong></center>";
}
if (!isset($_GET['pokaz'])) {
echo "<br />
<br />
<center><img src=\"/images/bmarrow2.gif\" alt=\"\" /> <a href=\"search.php?words=$words&amp;sf=$sf&amp;sp=$sp&amp;sa=$sa&amp;pokaz=wszystkie\">pokaż wszystkie</a></center>";
}
}

function displayCommentBox($id) {
echo'<h5 class="cufon" style="font-size:24px; margin:40px 0 -10px 0; float:left;">Rekomendacje:</h5>
<a class="poplight" rel="dodaj_komentarz" href="#?w=600" style="display:block; float:right; margin-top:40px; color:#488dc1; font-size:14px; text-decoration:underline;">dodaj rekomendację</a>
<div style="clear:both;"></div>';
$query = "SELECT * FROM firma_komentarze WHERE user_id= '$id'";
    $result = mysql_query ($query);
   while ($row = mysql_fetch_array ($result) ) {
	$autor = $row['autor'];
	$data = $row['data'];
	$tresc = $row['tresc'];
	echo'<div style="border-top:1px dotted #cdcdcd; margin: 10px 0; padding:10px 0;">
		<div style="float:left; width:60px; min-height:50px; margin-right:10px; background:url(images/cudzyslow.png) no-repeat top right;"></div>
		<div><p class="komentarz">'.$tresc.'</p><br><p class="komentarz_autor">'.$autor.'<p></div>
	</div>';
}

?>
<script type="text/javascript">
function validate_form_contact ( )
{
	valid = true;
        if ( document.contact_form.autor.value == "" )
        {
 				alert ( "wpisz Imię i Nazwisko" );
                valid = false;
        }
		if ( document.contact_form.telefon.value == "" )
        {
 				alert ( "wpisz telefon" );
                valid = false;
        }
		if (document.contact_form.telefon.value.length < 9)
		{
 				alert ( "nieprawidłowy numer telefonu" );
                valid = false;
        }
		 if ( document.contact_form.tresc.value == "" )
        {
 				alert ( "wpisz treść komentarza" );
                valid = false;
        }
        return valid;
}</script>
<?php
echo'<div id="dodaj_komentarz" class="popup_block rec" style="display: none;">
		<a class="close" href="#" onClick="$(\'#dodaj_komentarz\').fadeOut(); return false;"><img class="btn_close" title="Close" src="images/zamknij.png" alt="Close"></a>';
echo"<form method=\"post\" action=\"index.php?id=$id&amp;p=opinie\" name=\"contact_form\" onSubmit=\"return validate_form_contact ();\">
<input type=\"text\" name=\"autor\"  value=\"autor\" onblur=\"if(this.value=='')this.value='autor';\"  onfocus=\"if(this.value=='autor')this.value='';\" size=\"53\" class=\"text_form\" /><br />
<input type=\"text\" name=\"telefon\"  value=\"telefon\" onblur=\"if(this.value=='')this.value='telefon';\"  onfocus=\"if(this.value=='telefon')this.value='';\" size=\"53\"  class=\"text_form\"/><br />Numer telefonu nie zostanie wyświetlony na stronie, <br />służy jedynie możliwości potwierdzenia komentarza przez administratora strony.<br />
<textarea name=\"tresc\" cols=\"55\" rows=\"8\"onblur=\"if(this.value=='')this.value='komentarz';\"  onfocus=\"if(this.value=='komentarz')this.value='';\"  class=\"text_form\">komentarz</textarea><br />";
    generateToken();
    echo"<br />
    
<input name=\"kod\" type=\"text\" value=\"kod z obrazka\" onblur=\"if(this.value=='')this.value='kod z obrazka';\"  onfocus=\"if(this.value=='kod z obrazka')this.value='';\" size=\"10\" class=\"text_form\" style=\"width: 120px;\" /><br /><br />
<input type=\"hidden\" name=\"cadd\" value=\"cadd\"><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"image\" src=\"http://pobieramysie.pl/images/wyslij.jpg\" name=\"image\" id=\"go\">
</form>
";
echo "</center><br /><br />
";
echo'</div>';
}
function showKomisListBig($xx) {
echo "<table width=\"720\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"> <tr>
    <td class=\"komis_spacer\"> </td>
    <td class=\"komis_spacer\"> </td>
  </tr>";
 
$query = "SELECT * FROM portal_komis WHERE data2 >= CURDATE() ORDER BY data DESC, komis_id DESC LIMIT $xx";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	$cc = $row['kategoria'];
	 $query555 = "SELECT * from portal_komis_kategorie where cat_id = '$cc'";
       $result555 = mysql_query ($query555);
       while ($row555 = mysql_fetch_array ($result555)) {
      $catname = $row555['name'];
          }
	$close_arg = "";
	echo "<tr>
    <td valign=\"top\"><font class=\"tytul_newsa\">{$row['nazwa']}</font><br /><br />
	<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td align=\"left\" width=\"110\"><font class=\"firma_bold\">Wystawca:</font></td>
    <td align=\"left\" width=\"350\"><font class=\"gazeta\"> {$row['wystawca']}</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Kontakt:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['kontakt']}</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Kategoria:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> $catname</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Cena:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['cena']} zł</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Rodzaj:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['rodzaj']}</font></td>
  </tr>
</table>
<br />
<br />
	<font class=\"gazeta\"><font class=\"firma_bold\">Opis:</font> </font>{$row['opis']}</td>
    <td>";
	$kid = $row['komis_id'];
	//wyswietlanie minigalerii
	
	$pierwszy = 1;
	$query2 = "SELECT * FROM portal_komis_gp WHERE komis_id = '$kid'";
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	$pid = $row2['pic_id'];
	$did = $kid.$pid;
	echo "<div id=\"$did\""; if ($pierwszy == 0) { echo"style=\"display:none\"";} echo"><a href=\"javascript:pokazFoto('/upload/komis/$kid/{$row2['miniaturka']}')\"><img src=\"upload/komis/$kid/min_{$row2['miniaturka']}\" alt=\"kliknij by powiększyć\" border=\"0\" /></a></div>";
	
	if ($pierwszy == 1) $pierwszy = 0;
	
	$close_arg = $close_arg."overlayclose('$did'); ";
	
	}	
	
	echo"<br />
<br />
";
$licznik = 1;
$query3 = "SELECT * FROM portal_komis_gp WHERE komis_id = '$kid'";
    $result3 = mysql_query ($query3);
   
    while ($row3 = mysql_fetch_array ($result3) ) {
	
	$pid2 = $row3['pic_id'];
	$did2 = $kid.$pid2;
	echo "<a href=\"#\" onClick=\"$close_arg return overlay(this, '$did2')\" class=\"komis_button\">$licznik</a> ";
	
	$licznik ++;
	}	
echo"</td>
  </tr>
  <tr>
    <td class=\"komis_spacer\"> </td>
    <td class=\"komis_spacer\"> </td>
  </tr>"; 
	
	} 
	echo "</table>";	
}
function showArtListAll($min, $max, $cat) {$today = date('Y-m-d');
global $miesiace_nazwy;
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
if ($cat == '') {$query = "SELECT * FROM portal_porady WHERE data <= '$today' ORDER BY data DESC, news_id DESC"; }
else {$query = "SELECT * FROM portal_porady WHERE cat = '$cat' AND data <= '$today' ORDER BY data DESC, news_id DESC"; };
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	//echo"<div style=\"clear: both; display: table-row; height: 150px; border-bottom: solid 1px #E3D7DB;\">";
	if ($lp >= $min && $lp <= $max) {
	// echo "<table width=\"475\" cellspacing=\"0\" cellpadding=\"0\">
	// <tr><td>";
	$miniaturka = $row['miniaturka'];
	// if ($miniaturka != '') {
	 // echo "<br />
// <table width=\"228\" height=\"152\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
							  // <tr>
									// <td width=\"213\" height=\"137\"><a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><img src=\"/upload/portal/porady/min_{$row['miniaturka']}\" width=\"213\" height=\"137\" alt=\"{$row['tytul']}\" class=\"news_img\" /></a></td>
									// <td width=\"15\"></td>
									// <tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  // </tr>
								// </table>";
								// }echo "<a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><h2>{$row['tytul']}</h2></a><br />";
								// echo"{$row['lead']}<a href=\"porady.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a>
								// ";
	// echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
	
	$query2 = "SELECT * FROM portal_komentarze WHERE art_id = '{$row['news_id']}' AND potwierdzony = '1'";
	$result2 = mysql_query ($query2);
	$ilosc_komentarzy = mysql_num_rows($result2);
	
	$data = explode('-',$row['data']);
	$data = $data[2].' '.$miesiace_nazwy[ltrim($data[1],'0')].' '.$data[0];
	
	echo'<div><a href="porady.php?id='.$row['news_id'].'" title="'.$row['tytul'].'" style="float:left; margin: 0px 10px 10px 0;"><img src="/upload/portal/porady/min_'.$row['miniaturka'].'"></a>
	<h2 class="cufon"><a href="porady.php?id='.$row['news_id'].'" title="'.$row['tytul'].'" class="cufon" style="font-size:20px; color:#323232;">'.$row['tytul'].'</a></h2>
	<p class="data_newsa">'.$data.' | komentarze: '.$ilosc_komentarzy.'</p>
	'.$row['lead'].'
	<div style="clear:both;"></div>
	</div>
	<hr>';
	
		} 
	$lp++;
		} 
                
                /*
		$lp2 = 1;		
	$min_x = 1;	
	if ($cat == '') {$query2 = "SELECT * FROM portal_porady ORDER BY data DESC, news_id DESC"; }
else {$query2 = "SELECT * FROM portal_porady WHERE cat = '$cat' ORDER BY data DESC, news_id DESC"; };
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	   if ($max_x/10 == $max/10) echo "<u>$min_x - $max_x</u> | ";
	   else echo "<a href=\"porady.php?c=all&amp;min=$min_x&amp;max=$max_x&amp;cat=$cat\" title=\"kolejna strona\">$min_x - $max_x</a> | ";
	}
	
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}

                 */
}
function showAktListAll($min, $max) {
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
$query = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp >= $min && $lp <= $max) {
	echo "<table width=\"475\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td><br />
";
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	 echo "<table width=\"100\" height=\"56\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"84\" height=\"56\"><a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><img src=\"upload/portal/newsy/min_{$row['miniaturka']}\" width=\"84\" height=\"56\" alt=\"{$row['tytul']}\" class=\"news_img\" /></a></td>
									<td width=\"16\"></td>
								  </tr>
								</table>";
								}echo "<font class=\"data_newsa\">{$row['data']}</font><br /><a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><font class=\"tytul_newsa\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"show_akt.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a><br /><br />
								";
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
	}
	$lp++;
		} 
			
	$lp2 = 1;		
	$min_x = 1;	
	$query2 = "SELECT * FROM portal_newsy ORDER BY data DESC, news_id DESC";
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	echo "<a href=\"show_akt.php?c=all&amp;min=$min_x&amp;max=$max_x\"> $min_x - $max_x |</a>";
	}
	
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}
}
function showPrasaListAll($min, $max) {
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
$query = "SELECT * FROM portal_prasa ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp >= $min && $lp <= $max) {
	echo "<table width=\"461\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td>";
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	echo "<br />
<table width=\"170\" height=\"103\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"88\"><a href=\"prasa.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><img src=\"upload/portal/prasa/min_{$row['miniaturka']}\" width=\"155\" height=\"88\" alt=\"{$row['tytul']}\" class=\"news_img\"  /></a></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}echo "<font class=\"gazeta\">{$row['gazeta']}</font><br /><a href=\"prasa.php?id={$row['news_id']}\"><font class=\"tytul_newsa\" title=\"{$row['tytul']}\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"prasa.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a><br /><br />";
	 
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
		$lp++;
		}		
		
		$lp2 = 1;		
	$min_x = 1;	
	$query2 = "SELECT * FROM portal_prasa ORDER BY data DESC, news_id DESC";
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	echo "<a href=\"prasa.php?c=all&amp;min=$min_x&amp;max=$max_x\" title=\"następna strona: Prasa\"> $min_x - $max_x |</a>";
	}
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}
}
function getMatZgazetyAll($min, $max, $gazeta) {
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
$query = "SELECT * FROM portal_prasa WHERE gazeta = '$gazeta' ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp >= $min && $lp <= $max) {
	echo "<table width=\"1000\" cellspacing=\"0\" cellpadding=\"0\">
	<tr><td>";
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {
	echo "<br />
<table width=\"170\" height=\"103\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
								  <tr>
									<td width=\"155\" height=\"88\"><a href=\"prasa.php?id={$row['news_id']}\" title=\"{$row['tytul']}\"><img src=\"upload/portal/prasa/min_{$row['miniaturka']}\" width=\"155\" height=\"88\" alt=\"{$row['tytul']}\" class=\"news_img\"  /></a></td>
									<td width=\"15\"></td>
									<tr><td height=\"15\">&nbsp;</td><td></td></tr>
								  </tr>
								</table>";
								}echo "<font class=\"gazeta\">{$row['gazeta']}</font><br /><a href=\"prasa.php?id={$row['news_id']}\"><font class=\"tytul_newsa\" title=\"{$row['tytul']}\">{$row['tytul']}</font></a><br /><br />";
								echo"{$row['lead']}<a href=\"prasa.php?id={$row['news_id']}\" title=\"{$row['tytul']}\">(...)</a><br /><br />";
	echo "</td></tr><tr><td height=\"1\" bgcolor=\"#E3D7DB\"></td></tr></table>";
		} 
		$lp++;
		}		
			$lp2 = 1;		
	$min_x = 1;	
	$query2 = "SELECT * FROM portal_prasa WHERE gazeta = '$gazeta' ORDER BY data DESC, news_id DESC";
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	echo "<a href=\"prasa.php?c=all&amp;min=$min_x&amp;max=$max_x&amp;gazeta=$gazeta\" title=\"następna strona: Prasa\"> $min_x - $max_x |</a>";
	}
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}
}


function showKonkursListAll($page, $wns) {
if(!$page)
    $page = 1;
if(!$wns)
    $wns = 10;
$min = ($page - 1) * $wns + 1;
$max = $page * $wns;
$lp = 1;
$i=0;
global $miesiace_nazwy;
$query = "SELECT * FROM portal_konkursy ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	if ($lp >= $min && $lp <= $max) {
	$miniaturka = $row['miniaturka'];
	if ($miniaturka != '') {		
			$data = explode('-',$row['data']);
			$data = $data[2].' '.$miesiace_nazwy[ltrim($data[1],'0')].' '.$data[0];
			if($i%2==0)echo'<div style="float:left; width:295px; margin-right:15px;">';						
			else echo'<div style="float:left; width:295px;">';						
			echo'<h2 class="cufon"><a href="konkursy.php?id='.$row['news_id'].'" class="cufon" style="font-size:20px; color:#323232;">'.$row['tytul'].'</a></h2>';
			echo'<p class="data_newsa">'.$data.'</p>';
			echo'<a href="konkursy.php?id='.$row['news_id'].'"><img src="/upload/portal/konkursy/'.$row['miniaturka'].'" alt="'.$row['tytul'].'" style="width:295px;"/></a><hr>';
			echo'</div>';
			
			if($i%2==1)echo'<div style="clear:both;"></div>';
			$i++;
		}
	} 
        $lp++;    
    }
}
function showKomisListAll($min, $max, $sortuj, $kategoria) {
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
if ($sortuj == '') $sortuj = 'data';
echo "<table width=\"720\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"> <tr>
    <td class=\"komis_spacer\"> </td>
    <td class=\"komis_spacer\"> </td>
  </tr>";
 
if ($sortuj == 'data') $order = 'DESC'; 
else $order = 'ASC';
if ($kategoria != '') $where = "WHERE kategoria = '$kategoria' AND data2 >= CURDATE()"; else $where = 'WHERE data2 >= CURDATE()';
 $query = "SELECT * FROM portal_komis $where ORDER BY $sortuj $order, komis_id DESC";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	$cc = $row['kategoria'];
	 $query555 = "SELECT * from portal_komis_kategorie where cat_id = '$cc'";
       $result555 = mysql_query ($query555);
       while ($row555 = mysql_fetch_array ($result555)) {
      $catname = $row555['name'];
          }
	
	if ($lp >= $min && $lp <= $max) {
	$close_arg = "";
	echo "<tr>
    <td valign=\"top\"><font class=\"tytul_newsa\">{$row['nazwa']}</font><br /><br />
	<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td align=\"left\" width=\"110\"><font class=\"firma_bold\">Wystawca:</font></td>
    <td align=\"left\" width=\"350\"><font class=\"gazeta\"> {$row['wystawca']}</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Kontakt:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['kontakt']}</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Kategoria:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> $catname</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Cena:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['cena']} zł</font></td>
  </tr>
  <tr>
    <td align=\"left\"><font class=\"firma_bold\">Rodzaj:</font></td>
    <td align=\"left\"><font class=\"gazeta\"> {$row['rodzaj']}</font></td>
  </tr>
</table>
<br />
<br />
	<font class=\"gazeta\"><font class=\"firma_bold\">Opis:</font> </font>{$row['opis']}</td>
    <td>";
	$kid = $row['komis_id'];
	//wyswietlanie minigalerii
	
	$pierwszy = 1;
	$query2 = "SELECT * FROM portal_komis_gp WHERE komis_id = '$kid'";
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	$pid = $row2['pic_id'];
	$did = $kid.$pid;
	echo "<div id=\"$did\""; if ($pierwszy == 0) { echo"style=\"display:none\"";} echo"><a href=\"javascript:pokazFoto('/upload/komis/$kid/{$row2['miniaturka']}')\"><img src=\"upload/komis/$kid/min_{$row2['miniaturka']}\" alt=\"kliknij by powiększyć\" border=\"0\" /></a></div>";
	
	if ($pierwszy == 1) $pierwszy = 0;
	
	$close_arg = $close_arg."overlayclose('$did'); ";
	}
	
	
	echo"<br />
<br />
";
$licznik = 1;
$query3 = "SELECT * FROM portal_komis_gp WHERE komis_id = '$kid'";
    $result3 = mysql_query ($query3);
   
    while ($row3 = mysql_fetch_array ($result3) ) {
	
	$pid2 = $row3['pic_id'];
	$did2 = $kid.$pid2;
	echo "<a href=\"#\" onClick=\"$close_arg return overlay(this, '$did2')\" class=\"komis_button\">$licznik</a> ";
	
	$licznik ++;
	}	
echo"</td>
  </tr>
  <tr>
    <td class=\"komis_spacer\"> </td>
    <td class=\"komis_spacer\"> </td>
  </tr>"; 
	
	}	$lp++;
	} 
	echo "</table>";	
	
	$lp2 = 1;		
	$min_x = 1;	
	$query2 = "SELECT * FROM portal_komis WHERE data2 >= CURDATE() ORDER BY data DESC, komis_id DESC";
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	echo "<a href=\"komis.php?c=all&amp;min=$min_x&amp;max=$max_x&amp;sortuj=$sortuj&amp;kategoria=$kategoria\"> $min_x - $max_x |</a>";
	}
	
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}
}
function showKatalogAll($parent0, $parent1, $parent2, $parent3, $parent4, $min, $max, $wojewodztwo, $miasto_current) {
?>
  <script type="text/javascript" src="http://maps.targeo.pl/bubblemap/bubblemap.php?k=ZjdlYWI5NDZmYTNiNGI5YjhiY2QzMzFjYWM1YWQyMzIxMDE0MWNjMA==&chr=iso-8859-2">
</script>
<?php 
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
$cosjest= false;
//wyliczenie nowego warunku dla wojewodztwo/miasto
	if ($wojewodztwo != '' && $wojewodztwo != 'dowolne') {
		if ($miasto_current != '' && $miasto_current != 'dowolne') {
			$special_war = " AND u.najbl_miasto LIKE '$miasto_current'";
		} else { $special_war = " AND u.woj_id = '$wojewodztwo'"; }
	}
//echo $special_war;
$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, email, rabat, skypegg, logo, mapa, godzotw, subdomena, opinie FROM portal_abonamenty ORDER BY priorytet DESC";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
	$wyrozniony = $row7['wyroznienie'];
	$rabat  = $row7['rabat'];
	$email  = $row7['email'];
	$www = $row7['www'];
	$skypegg = $row7['skypegg'];
	$logo = $row7['logo'];
	$mapa = $row7['mapa'];
	$godzotw = $row7['godzotw'];
	$opinie = $row7['opinie'];
	$subdomena = $row7['subdomena'];
if ($parent0 == 0 && $parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
elseif ($parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.parent0 = '$parent0' AND f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
elseif ($parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
elseif ($parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
elseif ($parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3' AND f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
else
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3'AND f.parent4 = '$parent4' AND f.abonament_id = '$pri' AND f.user_id = u.user_id $special_war ORDER BY u.nazwa ASC";
//echo $query;
    $result = mysql_query ($query);
   if (mysql_affected_rows() == 0 && $cosjest= false)
	{
	echo "<br />
<br /><br /><center>:: brak pozycji w wybranej kategorii ::</center>
<br />";
	} else {$cosjest= true;}
	
	
    while ($row = mysql_fetch_array ($result) ) {
	
	//test czy aktywne!!!
	
	 $user_fc_id = $row['user_id'];
	
	 $query_active = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id' AND aktywne != '0' ";
       $result_active = mysql_query ($query_active);
	   if (mysql_affected_rows() != 0) {
	  
	  
	  	
	if ($lp >= $min && $lp <= $max) {
	//echo $pri.'-';
	// zapis informacji o wyświetleniu w katalogu
	$query555 = "SELECT * FROM katalog_counter WHERE user_id = '$user_fc_id' ";
       $result555 = mysql_query ($query555);
	   if (mysql_affected_rows() == 0) {
	   //insert
	   mysql_query("insert into katalog_counter (user_id, counter) VALUES ('$user_fc_id', 1)");
	   } else {
       while ($row555 = mysql_fetch_array ($result555)) {
	   $counter = $row555['counter'];
	   $counter++;
	   }
		mysql_query("update katalog_counter SET counter= '$counter' WHERE user_id= '$user_fc_id'");
	   }
	/*if ($wojewodztwo != '' && $wojewodztwo != 'dowolne') {
		if ($miasto_current != '' && $miasto_current != 'dowolne') {
			$query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id' AND najbl_miasto = '$miasto_current'";
		} else $query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id' AND woj_id = '$wojewodztwo'";
	}
	else*/ $query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	$firma = $row2['nazwa'];
	$query4 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id'";
    $result4 = mysql_query ($query4);
    while ($row4 = mysql_fetch_array ($result4) ) {
	$aktywne = $row4['aktywne'];
	if ($aktywne != 0) {
	$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
    $result3 = mysql_query ($query3);
    while ($row3 = mysql_fetch_array ($result3) ) {
	$user_log = $row3['user'];
	}
	$wizytowka = $row2['wizytowka'];
		echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 2px #cb108b; padding:2px;\""; echo">";
	echo "<table width=\"470\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"470\" colspan=\"2\" align=\"left\" valign=\"top\">
";
								?>
                              <?php
								echo "<a name=\"fr$id\"></a>"; if ($subdomena == 'tak') { echo "<a title=\"Pokaż szczegóły {$firma}\"  href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<font class=\"tytul_newsa\">$firma</font>"; if ($subdomena == 'tak') { echo "</a>"; } 
								$miasto_do_adres = $row2['miasto'];
								$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
								$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
								$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
								$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
								$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
								$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
								$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
								$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
								$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
								$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
								$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
								$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
								$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
								$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
								$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
								$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
								$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
								$ulica_do_adres = $row2['ulica'];
								$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
								$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
								$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
								$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
								$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
								$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
								$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
								$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
								$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
								$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
								$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
								$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
								$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
								$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
								$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
								$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
								$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
								//$ulica_do_adres = iconv("ISO-8859-1","UTF-8",$ulica_do_adres);
    $firmId = $row2['user_id'];
    $firmaMiasto = $row2['miasto'];
    $parent0=$_GET['parent0'];
    $parent1=$_GET['parent1'];
    
    $query_category = "SELECT * FROM firma_treeplacement_adv  WHERE user_id = '$firmId' LIMIT 1";
    $result_category = mysql_query ($query_category);
    
    while ($row_category = mysql_fetch_array ($result_category) ) {
        $IdParent0 = $row_category['parent0'];
 
        }
echo "<br /><br />
</td></tr> <tr>
    <td width=\"280\" align=\"left\" valign=\"top\"><a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;lokacja={$row2['woj_id']}#cattree\">";
//getTitleCategoryFirm1($firmId);
if (empty($parent1)) getTitleCategory($parent0);   
else getTitleCategoryBig($parent1); 
     
$wojewodztwo2 = $row2['woj_id'];
if ($wojewodztwo2 == 1)  echo' dolnośląskie';
if ($wojewodztwo2 == 2)  echo' kujawsko-pomorskie';
if ($wojewodztwo2 == 3) echo' lubelskie';
if ($wojewodztwo2 == 4) echo' lubuskie';
if ($wojewodztwo2 == 5) echo' łódzkie';
if ($wojewodztwo2 == 6) echo' małopolskie';
if ($wojewodztwo2 == 7) echo' mazowieckie';
if ($wojewodztwo2 == 8) echo' opolskie';
if ($wojewodztwo2 == 9) echo' podkarpackie';
if ($wojewodztwo2 == 10) echo' podlaskie';
if ($wojewodztwo2 == 11) echo' pomorskie';
if ($wojewodztwo2 == 12) echo' śląskie';
if ($wojewodztwo2 == 13) echo' świętokrzyskie';
if ($wojewodztwo2 == 14) echo' warmińsko-mazurskie';
if ($wojewodztwo2 == 15) echo' wielkopolskie';
if ($wojewodztwo2 == 16) echo' zachodniopomorskie';
echo "</a><br /><a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;lokacja={$row2['woj_id']}&amp; ;$firmaMiasto#cattree\">";
//getTitleCategoryFirm1($firmId);
if (empty($parent1)) getTitleCategory($parent0);   
else getTitleCategoryBig($parent1); 
echo " {$row2['miasto']}</a><br /><br />";
if (!empty($row2['ulica'])) echo "ul. ";
echo "{$row2['ulica']} {$row2['nrdomu']}<br />{$row2['kod']} {$row2['miasto']}<br />woj."; 
$wojewodztwo2 = $row2['woj_id'];
if ($wojewodztwo2 == 1)  echo' dolnośląskie';
if ($wojewodztwo2 == 2)  echo' kujawsko-pomorskie';
if ($wojewodztwo2 == 3) echo' lubelskie';
if ($wojewodztwo2 == 4) echo' lubuskie';
if ($wojewodztwo2 == 5) echo' łódzkie';
if ($wojewodztwo2 == 6) echo' małopolskie';
if ($wojewodztwo2 == 7) echo' mazowieckie';
if ($wojewodztwo2 == 8) echo' opolskie';
if ($wojewodztwo2 == 9) echo' podkarpackie';
if ($wojewodztwo2 == 10) echo' podlaskie';
if ($wojewodztwo2 == 11) echo' pomorskie';
if ($wojewodztwo2 == 12) echo' śląskie';
if ($wojewodztwo2 == 13) echo' świętokrzyskie';
if ($wojewodztwo2 == 14) echo' warmińsko-mazurskie';
if ($wojewodztwo2 == 15) echo' wielkopolskie';
if ($wojewodztwo2 == 16) echo' zachodniopomorskie';
 if ($mapa == 'tak') { echo "<br />
<a title=\"Firma {$firma} na mapie\" href=\"";
$targeo = $row2['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row2['nrdomu']}"; echo "\">firma na mapie</a>"; } echo " <br /><br />
";
?>
							
<script type="text/javascript">
function myPopup3<? echo $user_fc_id; ?>() {
window.open( "mailer.php?id=<? echo $user_fc_id; ?>", "myWindow", "status = 1, height = 300, width = 600, resizable = 0" )
}
</script>
<?php
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
 ";
								if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $email == 'tak') { echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">E-mail:</font></td>"; echo"
																<td align=\"left\"><a href=\"";
								if ($subdomena == 'tak' && $email == 'tak') {
								echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
								} else {
								echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
								}
																 echo ">Napisz do nas!</a></td>
															  </tr>";}
								if ($row2['www'] != '' && $www == 'tak') {
								$xtr = $row2['www'];
								if (strlen($xtr) > 32) $xtr = "przejdź na WWW";
								echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">WWW: </font> </td>
																<td align=\"left\"><a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">$xtr</a></td>
															  </tr>";
															  
															  }
															  echo "</table>";
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
								if ($row2['telefon'] != '') {
								$telefon = $row2['telefon'];
								$telefon = ereg_replace(",", ",<br>", $telefon);
								echo "<tr>
					<td align=\"left\" width=\"50\"><font class=\"firma_bold\">Tel.:</font></td>
					<td align=\"left\" width=\"125\">$telefon</td>
				    </tr>";}
								if ($row2['fax'] != '') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Fax:</font></td>
					<td align=\"left\">{$row2['fax']}</td>
				    </tr>";
								if ($row2['skype'] != '' && $skypegg == 'tak') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Skype:</font></td>
					<td align=\"left\" valign=\"middle\">					
								<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
								if ($row2['gg'] != '' && $skypegg == 'tak') { echo "<font class=\"firma_bold\">GG:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; } else {echo "<br />";}
								echo "</td>
				    </tr> </table>";
					echo "</td><td width=\"190\" align=\"right\">	";		
					 echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\" width=\"190\">";
	 if ($wizytowka != ''&& $logo == 'tak') {
								  echo "<tr>
								  <td width=\"10\"></td>
									<td align=\"right\" valign=\"top\">"; if ($subdomena == 'tak') {  echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<img src=\"upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"Logo {$firma} [ {$user_log} ]\" class=\"news_img\" />"; if ($subdomena == 'tak') {  echo"</a>"; } echo "</td>
								  </tr>"; } echo "
								  <tr> <td width=\"10\"></td>
								  <td align=\"center\">"; 
								  if ($rabat == 'tak') { 
								$query66666 = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
								$result66666 = mysql_query ($query66666);
							   if (mysql_affected_rows() > 0 )
								{
								while ($row66666 = mysql_fetch_array ($result66666) ) {
								$rabacik = $row66666['tytul'];
								}
								echo "<br />
<br />
<font class=\"rabacik\"><strong>$rabacik</strong></font>";
								}
								}
								  echo "</td></tr>
								</table>";			
							echo "</td></tr></table>";	
								?>
<script type="text/javascript">
function myPopup2<? echo $user_fc_id; ?>() {
window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
"status = 1, height = 150, width = 300, resizable = 0, top = 250, left = 450" )
}
</script>
<?php
												echo "<br /><a href=\"#fr$id\" onclick=\"myPopup2".$user_fc_id."()\"  ><font class=\"gazeta\">dodaj do ulubionych</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; if ($subdomena == 'tak' && $opinie == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=opinie\"><font class=\"gazeta\">zobacz opinie</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } if ($subdomena == 'tak') { echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\"><font class=\"gazeta\">zobacz więcej</font></a>"; } 
								echo"</div><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
	}
}}}
 $lp++; }	}
}

$lp2 = 1;		
$min_x = 1;	
	$xfq = 0;
	$query7 = "SELECT abonament_id, priorytet FROM portal_abonamenty ORDER BY priorytet DESC";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
		
	if ($parent0 == 0 && $parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
elseif ($parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
elseif ($parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
elseif ($parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
elseif ($parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
else
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3'AND f.parent4 = '$parent4' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND p.aktywne = '1' $special_war ORDER BY u.nazwa ASC";
	//echo $query2.'<br/>';
	    $result2 = mysql_query ($query2);
	$xcq = mysql_affected_rows();
	//echo ' - '.$xcq.'<br/>';
	$xfq = $xfq + $xcq;
    /* while ($row2 = mysql_fetch_array ($result2) ) {
	$user_fc_id2 = $row2['user_id'];
	
	 $query_active2 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id2' AND aktywne = '1' ";
       $result_active2 = mysql_query ($query_active2);
	   if (mysql_affected_rows() != 0) {
	
	
	if ($lp2 == 1) {
		$max_x = $min_x + 9;
	
		$minNumber = $min;
		echo " ";
		if ($minNumber == $min_x)  echo "<u>";
			echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;wojewodztwo=$wojewodztwo&amp;miasto=$miasto_current#cattree\" title=\"następna strona: Katalog firm\">$min_x - $max_x</a>";
		if ($minNumber == $min_x)  echo "</u>";
		echo " |";
		
	}
	 $min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	
	}
	}
	*/}
	//echo $xfq;
	for ($i = 1; $i <= $xfq; $i++) {
	
            $temp = explode(";", $_GET['lokacja']);
  $id_miasto_current = $temp[1];
	
	if ($lp2 == 1) {
		$max_x = $min_x + 9;
		
		echo " ";
		
			echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;lokacja=$wojewodztwo&amp; ;$id_miasto_current#cattree\" title=\"następna strona: Katalog firm\">$min_x - $max_x</a>";
		
		echo " |";
		
	}
	 $min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}
}

function showRabatyListAll($min, $max) {
if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 0;

$query = "SELECT * FROM firma_rabaty as f, firma_details as d, portal_abonamenty as p WHERE f.user_id = d.user_id AND d.abonament_id = p.abonament_id AND p.rabat = 'tak' ORDER BY p.priorytet DESC";
//$query = "SELECT * FROM firma_rabaty ORDER BY data DESC, news_id DESC";
    $result = mysql_query ($query);
   if (mysql_affected_rows() == 0 )
	{
	
	echo "<br />
<br /><br /><center>:: brak pozycji w wybranej kategorii ::</center>
<br />";
	}
    
    while ($row = mysql_fetch_array ($result) ) {

	//if ($lp >= $min && $lp <= $max) {
	if (TRUE) {
	$user_fc_id = $row['user_id'];
	$rabacik = $row['tytul'];
	$query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
	
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	$firma = $row2['nazwa'];
	$abid = $row2['abonament_id'];
	$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, rabat, email, skypegg, logo, mapa, godzotw, opinie FROM portal_abonamenty WHERE abonament_id = '$abid'";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
	$wyrozniony = $row7['wyroznienie'];
	$rabat  = $row7['rabat'];
	$email = $row7['email'];
	$www = $row7['www'];
	$skypegg = $row7['skypegg'];
	$logo = $row7['logo'];
	$mapa = $row7['mapa'];
	$godzotw = $row7['godzotw'];
	$opinie = $row7['opinie'];
	}
	$query4 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id'";
	
    $result4 = mysql_query ($query4);
   
    while ($row4 = mysql_fetch_array ($result4) ) {
        
       
            
	$aktywne = $row4['aktywne'];
	
	if ($aktywne != 0) {

            $lp++;
            
            if($lp >= $min && $lp <= $max) {
            
	$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
	
    $result3 = mysql_query ($query3);
   
    while ($row3 = mysql_fetch_array ($result3) ) {
	
	$user_log = $row3['user'];
	
	}
	$wizytowka = $row2['wizytowka'];
	
		echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 2px #cb108b; padding:2px;\""; echo">";
	
	echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td align=\"left\" valign=\"top\">
";
	
	?>
                                <script type="text/javascript" src="http://maps.targeo.pl/bubblemap/bubblemap.php?k=ZjdlYWI5NDZmYTNiNGI5YjhiY2QzMzFjYWM1YWQyMzIxMDE0MWNjMA==&chr=iso-8859-2">
</script>
                              <?php
							  
							  $miasto_do_adres = $row2['miasto'];
								$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
								$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
								$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
								$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
								$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
								$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
								$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
								$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
								$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
								$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
								$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
								$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
								$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
								$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
								$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
								$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
								$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
								$ulica_do_adres = $row2['ulica'];
								$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
								$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
								$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
								$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
								$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
								$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
								$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
								$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
								$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
								$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
								$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
								$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
								$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
								$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
								$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
								$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
								$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
							  
								echo "<a name=\"fr$id\"></a>"; if ($www == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<font class=\"tytul_newsa\">$firma</font>"; if ($www == 'tak') { echo "</a>"; } echo "<br />
<br />ul. {$row2['ulica']} {$row2['nrdomu']}<br />{$row2['kod']} {$row2['miasto']}"; if ($mapa == 'tak') { echo "<br />
<a title=\"Firma {$firma} na mapie\" href=\"";
$targeo = $row2['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row2['nrdomu']}"; echo "\">firma na mapie</a>"; } echo " <br /><br />
";
?>
							
<script type="text/javascript">
function myPopup3<? echo $user_fc_id; ?>() {
window.open( "mailer.php?id=<? echo $user_fc_id; ?>", "myWindow", "status = 1, height = 300, width = 600, resizable = 0" )
}
</script>
<?php
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
 ";
								if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $www == 'tak' && $email == 'tak') { echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">E-mail:</font></td>";
				echo"												<td align=\"left\"><a href=\"";
								if ($www == 'tak' && $email == 'tak') {
								echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
								} else {
								echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
								}
																 echo ">Napisz do nas!</a></td>
															  </tr>"; }
								if ($row2['www'] != '' && $www == 'tak') echo " <tr>
																<td align=\"left\" width=\"50\"><font class=\"firma_bold\">WWW: </font> </td>
																<td align=\"left\"><a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">{$row2['www']}</a></td>
															  </tr>";
															  echo "</table>";
								
								echo "	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
								if ($row2['telefon'] != '') {
								$telefon = $row2['telefon'];
								$telefon = ereg_replace(",", ",<br>", $telefon);
								
								echo "<tr>
					<td align=\"left\" width=\"50\"><font class=\"firma_bold\">Tel.:</font></td>
					<td align=\"left\" width=\"125\">$telefon</td>
				    </tr>";}
								if ($row2['fax'] != '') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Fax:</font></td>
					<td align=\"left\">{$row2['fax']}</td>
				    </tr>";
								if ($row2['skype'] != '' && $skypegg == 'tak') echo "<tr>
					<td align=\"left\" width=\"25\"><font class=\"firma_bold\">Skype:</font></td>
					<td align=\"left\" valign=\"middle\">					
								<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a>";
								if ($row2['gg'] != '' && $skypegg == 'tak') { echo " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"firma_bold\">GG:</font>&nbsp;&nbsp;&nbsp;<a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; } else {echo "<br />";}
								echo "</td>
				    </tr> </table>";
								
								
						echo "</td><td width=\"190\" align=\"right\">	";		
	 echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\" width=\"190\">";
	 if ($wizytowka != ''&& $logo == 'tak') {
								  echo "<tr>
								  <td width=\"10\"></td>
									<td align=\"right\">"; if ($www == 'tak') {  echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } echo "<img src=\"/../upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"Logo {$firma}\" class=\"news_img\" width=\"80%\" height=\"80%\" />"; if ($www == 'tak') {  echo"</a>"; } echo "</td>
									
								  </tr>"; } echo "
								  <tr> <td width=\"10\"></td>
								  <td align=\"center\">"; 
								  
								  
					 if ($rabat == 'tak') { 
								$query222 = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
								$result222 = mysql_query ($query222);
							   if (mysql_affected_rows() > 0 )
								{
								//$lp++;
								while ($row222 = mysql_fetch_array ($result222) ) {
								$rabacik = $row222['tytul'];
								}
								echo "<br />
<br />
<font class=\"rabacik\"><strong>$rabacik</strong></font>";
								}
					}
								  
								  echo "</td></tr>
								</table>";			
								
					echo "</td></tr></table>";	
					
	?>
<script type="text/javascript">
function myPopup2<? echo $user_fc_id; ?>() {
window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
"status = 1, height = 150, width = 300, resizable = 0" )
}
</script>

<?php
							
	echo "<br /><a href=\"#fr$id\" onclick=\"myPopup2".$user_fc_id."()\"  ><font class=\"gazeta\">dodaj do ulubionych</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; if ($subdomena == 'tak' && $opinie == 'tak') { echo "<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=opinie\"><font class=\"gazeta\">zobacz opinie</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } if ($subdomena == 'tak') { echo"<a href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4\"><font class=\"gazeta\">zobacz więcej</font></a>"; } echo "</div>";
								
							
								echo"<br /><br />
								<img src=\"images/news_line.jpg\" alt=\"\" width=\"100%\" /><br /><br />";
 }
  } } 
    
       }
        }
	} 
	
	
		$lp2 = 1;		
	$min_x = 1;	
	$query2 = "SELECT * FROM firma_rabaty ORDER BY data DESC, news_id DESC";
    $result2 = mysql_query ($query2);
   
    while ($row2 = mysql_fetch_array ($result2) ) {
	
	if ($lp2 == 1) {
	$max_x = $min_x + 9;
	//echo "<a href=\"rabaty.php?c=all&amp;min=$min_x&amp;max=$max_x\"> $min_x - $max_x |</a>";
	}
	
	$min_x ++;
	if ($lp2 == 10) { $lp2 = 1; } else { $lp2 ++; }
	}

}

function printCompany($id) {
	$query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
	$firma = $row['nazwa'];
		$wizytowka = $row['wizytowka'];
	if ($wizytowka != '') {
	 echo "<table width=\"280\" height=\"165\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"right\">
								  <tr>
									<td width=\"270\" height=\"165\"><img src=\"http://pobieramysie.pl/upload/firma/$id/details/{$row['wizytowka']}\" alt=\"Logo {$firma}\" class=\"firma_img\" /></td>
									<td width=\"10\"></td>
								  </tr>
								</table>";
								}?>
                                <?php
								 $miasto_do_adres = $row['miasto'];
								$miasto_do_adres = strtr($miasto_do_adres, " ", "+");
								$miasto_do_adres = strtr($miasto_do_adres, "ą", "a");
								$miasto_do_adres = strtr($miasto_do_adres, "Ą", "A");
								$miasto_do_adres = strtr($miasto_do_adres, "Ć", "C");
								$miasto_do_adres = strtr($miasto_do_adres, "ć", "c");
								$miasto_do_adres = strtr($miasto_do_adres, "Ę", "E");
								$miasto_do_adres = strtr($miasto_do_adres, "ę", "e");
								$miasto_do_adres = strtr($miasto_do_adres, "Ł", "L");
								$miasto_do_adres = strtr($miasto_do_adres, "ł", "l");
								$miasto_do_adres = strtr($miasto_do_adres, "Ń", "N");
								$miasto_do_adres = strtr($miasto_do_adres, "ń", "n");
								$miasto_do_adres = strtr($miasto_do_adres, "Ó", "O");
								$miasto_do_adres = strtr($miasto_do_adres, "ó", "o");
								$miasto_do_adres = strtr($miasto_do_adres, "Ś", "S");
								$miasto_do_adres = strtr($miasto_do_adres, "ś", "s");
								$miasto_do_adres = strtr($miasto_do_adres, "Ź", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ź", "z");
								$miasto_do_adres = strtr($miasto_do_adres, "Ż", "Z");
								$miasto_do_adres = strtr($miasto_do_adres, "ż", "z");
								$ulica_do_adres = $row['ulica'];
								$ulica_do_adres = strtr($ulica_do_adres, " ", "+");
								$ulica_do_adres = strtr($ulica_do_adres, "ą", "a");
								$ulica_do_adres = strtr($ulica_do_adres, "Ą", "A");
								$ulica_do_adres = strtr($ulica_do_adres, "Ć", "C");
								$ulica_do_adres = strtr($ulica_do_adres, "ć", "c");
								$ulica_do_adres = strtr($ulica_do_adres, "Ę", "E");
								$ulica_do_adres = strtr($ulica_do_adres, "ę", "e");
								$ulica_do_adres = strtr($ulica_do_adres, "Ł", "L");
								$ulica_do_adres = strtr($ulica_do_adres, "ł", "l");
								$ulica_do_adres = strtr($ulica_do_adres, "Ń", "N");
								$ulica_do_adres = strtr($ulica_do_adres, "ń", "n");
								$ulica_do_adres = strtr($ulica_do_adres, "Ó", "O");
								$ulica_do_adres = strtr($ulica_do_adres, "ó", "o");
								$ulica_do_adres = strtr($ulica_do_adres, "Ś", "S");
								$ulica_do_adres = strtr($ulica_do_adres, "ś", "s");
								$ulica_do_adres = strtr($ulica_do_adres, "Ź", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ź", "z");
								$ulica_do_adres = strtr($ulica_do_adres, "Ż", "Z");
								$ulica_do_adres = strtr($ulica_do_adres, "ż", "z");
								echo "<font class=\"firma_tytul\">$firma</font><br /><br />";
								echo"<font class=\"firma_details\">ul. {$row['ulica']} {$row['nrdomu']}<br />
							{$row['miasto']} {$row['kod']} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class=\"firma_link\"  title=\"Firma {$firma} na mapie\" href=\"";
$targeo = $row['targeo']; if ($targeo != '') echo "http://adres.targeo.pl/$targeo"; else echo "http://adres.targeo.pl/$miasto_do_adres,$ulica_do_adres,{$row['nrdomu']}"; echo "\">firma na mapie</a><br /><br />";
							
								if ($row['www'] != '') echo "<strong>Strona WWW:</strong> <a href=\"http://{$row['www']}\" target=\"_blank\">{$row['www']}</a><br />";
								
								if ($row['telefon'] != '') {
								$telefon = $row['telefon'];
								$telefon = ereg_replace(",", ",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $telefon);
								
								echo "<strong>Telefon:</strong> $telefon<br />";}
								if ($row['fax'] != '') echo "<strong>Fax:</strong> {$row['fax']}<br />";
								if ($row2['skype'] != '') echo "<strong>Skype:</strong> {$row2['skype']} 					
								<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" width=\"34\" height=\"34\" alt=\"Skype MeT!\" /></a><br />";
								if ($row2['gg'] != '') echo "<strong>Gadu-Gadu:</strong> {$row2['gg']} <a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\" /></a><br />";
								if ($row['godz'] != '') echo "<strong>Godziny otwarcia:</strong><br />pn.pt.: {$row['godz']}<br />";
								if ($row['godz2'] != '') echo "sob.: {$row['godz2']}<br /><br />";
				 					echo "</font>";
	}
}
function generateToken() {
$lp = rand(1,5);
echo '<img src="http://pobieramysie.pl/images/obr/'.$lp.'.jpg" alt="" border="0" /> <input type="hidden" name="tn" value="'.$lp.'" />';
}
function date_diff2($date1, $date2)
{
//$date1  today, or any other day
//$date2  date to check against
$d1 = explode("-", $date1);
$y1 = $d1[0];
$m1 = $d1[1];
$d1 = $d1[2];
$d2 = explode("-", $date2);
$y2 = $d2[0];
$m2 = $d2[1];
$d2 = $d2[2];
$date1_set = mktime(0,0,0, $m1, $d1, $y1);
$date2_set = mktime(0,0,0, $m2, $d2, $y2);
return(round(($date2_set-$date1_set)/(60*60*24)));
}
function readPage($id)
{
	$query = "SELECT tresc FROM pages WHERE page_id = '$id'";
    $result = mysql_query ($query);
   
    while ($row = mysql_fetch_array ($result) ) {
	 echo "{$row['tresc']}";
		} 
}
//START
//----------------------------------------------------------Generowanie Title, Description i Keywordów do FIRM
function getTitle($id) {
    $query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['nazwa'].', '.$row['miasto'];
	}
}
function getTitle2($id) {
    $query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['klucz'];
	}
}
function getDescription($id) {
    $query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['nazwa'].' - '.$row['miasto'].', ul. '.$row['ulica'];
	}
}
function getKeywords($id) {
    $query = "SELECT * FROM firma_details WHERE user_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['nazwa'].', '.$row['miasto'].', '.$row['ulica'];
	}
}
//----------------------------------------------------------Generowanie Title, Description i Keywordów do ARTYKULOW
function getTitleArt($id) {
    $query = "SELECT * FROM portal_porady WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'];
	}
}
function getDescriptionArt($id) {
    $query = "SELECT * FROM portal_porady WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['lead'].' ';
	}
}
function getKeywordsArt($id) {
    $query = "SELECT * FROM portal_porady WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        $Keywords = explode(' ',strtolower($row['tytul']));
        $ileKeywords = count($Keywords);
        $wyswKeywords = strtolower($row['tytul']);
        $wyswKeywords.=',';
        
        for ($i=0;$i<$ileKeywords;$i++) {
            $keyword = strtr($Keywords[$i], "!", " ");
            $keyword = strtr($keyword, "?", " ");
            $keyword = strtr($keyword, ".", " ");
            $keyword = strtr($keyword, ",", " ");
            if (strlen($Keywords[$i]) > 3) $wyswKeywords.= $keyword.',';
        
        }
        
        echo $wyswKeywords;
       
        
        
	}
}
//----------------------------------------------------------Generowanie Title, Description i Keywordów do PRASY
function getTitlePress($id) {
    $query = "SELECT * FROM portal_prasa WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' - ';
	}
}
function getDescriptionPress($id) {
    $query = "SELECT * FROM portal_prasa WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' - '.$row['lead'].' ';
	}
}
function getKeywordsPress($id) {
    $query = "SELECT * FROM portal_prasa WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].', '.$row['gazeta'].', ';
	}
}
//----------------------------------------------------------Generowanie Title, Description i Keywordów do NEWSOW
function getTitleNews($id) {
    $query = "SELECT * FROM portal_newsy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' - ';
	}
}
function getDescriptionNews($id) {
    $query = "SELECT * FROM portal_newsy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' ('.$row['data'].') - '.$row['lead'].' ';
	}
}
function getKeywordsNews($id) {
    $query = "SELECT * FROM portal_newsy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].', ';
	}
}
//----------------------------------------------------------Generowanie Title, Description i Keywordów do KONKURSOW
function getTitleCompetition($id) {
    $query = "SELECT * FROM portal_konkursy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' - ';
	}
}
function getDescriptionCompetition($id) {
    $query = "SELECT * FROM portal_konkursy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].' ('.$row['data'].') - '.$row['lead'].' ';
	}
}
function getKeywordsCompetition($id) {
    $query = "SELECT * FROM portal_konkursy WHERE news_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['tytul'].', ';
	}
}
//----------------------------------------------------------Generowanie Title, Description i Keywordów do KATALOGU FIRM
function getTitleFirm($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo ' / ';
        echo $row['name'];
	}
}
function getTitleFirm1($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['name'];
	}
}
function getKeywordsFirm($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['name'];
        echo ', ';
	}
}
function getDescriptionFirm($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['parent1'];
	}
}
//----------------------------------------------------------KONIEC generowania
function getTitleCategory($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['name'];
        
	}
}
function getTitleCategoryBig($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo ucfirst($row['name']);
        
	}
}
function getTitleCategory2($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {

        return $row['name'];
        
	}
}
function getTitleCategoryBig2($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {

        return ucfirst($row['name']);
        
	}
}
function getTitleCategoryA($id) {
    $query = "SELECT * FROM portal_tree WHERE galaz_id = '$id'";
    $result = mysql_query ($query);
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['name'];
        
        echo ' / ';
	}
}
function getTitleCategoryFirm1($id) {
    $query = "SELECT * FROM firma_treeplacement_adv  WHERE user_id = '$id' AND parent1 = 0";
    $result = mysql_query ($query);
    
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['node_name'];
 
	}
}
function getTitleCategoryFirm2a($id) {
    $query = "SELECT * FROM firma_treeplacement_adv WHERE user_id = '$id' AND parent2 = 0 AND parent1 != 0 ORDER BY place_id ASC LIMIT 1";
    $result = mysql_query ($query);
    
    while ($row = mysql_fetch_array ($result) ) {
        echo $row['node_name'];
	}
}
function getOkres() {
 $query = "SELECT value from portal_config where name = 'okres_testowy'";
       $result = mysql_query ($query);
       while ($row = mysql_fetch_array ($result)) {
	  $okres_testowy = $row['value'];
	   
	   }
	   return $okres_testowy;
}
function showKatalogAll_NEW($parent0, $parent1, $parent2, $parent3, $parent4, $min, $max, $wojewodztwo, $miasto_current) {

if ($min == '') $min = 1;
if ($max == '') $max = $min + 9;
$lp = 1;
$cosjest= false;
//wyliczenie nowego warunku dla wojewodztwo/miasto
	if ($wojewodztwo != '' && $wojewodztwo != 'dowolne') {
		if ($miasto_current != '' && $miasto_current != 'dowolne') {
			$special_war = " AND u.najbl_miasto LIKE '$miasto_current'";
		} else { $special_war = " AND u.woj_id = '$wojewodztwo'"; }
	}
$query7 = "SELECT abonament_id, priorytet, wyroznienie, www, email, rabat, skypegg, logo, mapa, godzotw, subdomena, opinie,opis FROM portal_abonamenty ORDER BY priorytet DESC";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
	$wyrozniony = $row7['wyroznienie'];
	$rabat  = $row7['rabat'];
	$email  = $row7['email'];
	$www = $row7['www'];
	$skypegg = $row7['skypegg'];
	$logo = $row7['logo'];
	$mapa = $row7['mapa'];
	$godzotw = $row7['godzotw'];
	$opinie = $row7['opinie'];
	$subdomena = $row7['subdomena'];
	$opis = $row7['opis'];
	if ($parent0 == 0 && $parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent3 == 0  && $parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent4 == 0)   
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
else
$query = "SELECT DISTINCT f.user_id, u.nazwa FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3'AND f.parent4 = '$parent4' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
//echo $query;
    $result = mysql_query ($query);
   if (mysql_affected_rows() == 0 && $cosjest= false)
	{
	echo "<br />
<br /><br /><center>:: brak pozycji w wybranej kategorii ::</center>
<br />";
	} else {$cosjest= true;}
	
	
    while ($row = mysql_fetch_array ($result) ) {
	
	
	
	 $user_fc_id = $row['user_id'];
	
	 $query_active = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id' AND aktywne != '0' ";
       $result_active = mysql_query ($query_active);
	   if (mysql_affected_rows() != 0) {
	  
	  
	  	
	if ($lp >= $min && $lp <= $max) {
	// echo $pri.'-';
	// zapis informacji o wyświetleniu w katalogu
	$query555 = "SELECT * FROM katalog_counter WHERE user_id = '$user_fc_id' ";
       $result555 = mysql_query ($query555);
	   if (mysql_affected_rows() == 0) {
	   //insert
	   mysql_query("insert into katalog_counter (user_id, counter) VALUES ('$user_fc_id', 1)");
	   } else {
       while ($row555 = mysql_fetch_array ($result555)) {
	   $counter = $row555['counter'];
	   $counter++;
	   }
		mysql_query("update katalog_counter SET counter= '$counter' WHERE user_id= '$user_fc_id'");
	   }
	 $query2 = "SELECT * FROM firma_details WHERE user_id = '$user_fc_id'";
	 // echo $query2;
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_array ($result2) ) {
	$firma = $row2['nazwa'];
	$query4 = "SELECT aktywne FROM firma_platnosci WHERE user_id = '$user_fc_id'";
    $result4 = mysql_query ($query4);
    while ($row4 = mysql_fetch_array ($result4) ) {
	$aktywne = $row4['aktywne'];
	if ($aktywne != 0) {
	$query3 = "SELECT user FROM users WHERE user_id = '$user_fc_id'";
    $result3 = mysql_query ($query3);
    while ($row3 = mysql_fetch_array ($result3) ) {
	$user_log = $row3['user'];
	}
	$wizytowka = $row2['wizytowka'];
	echo "<div "; if ($wyrozniony == 'tak') echo "style=\"border: solid 1px #cb108b; padding:10px;  margin-bottom:30px;\""; else echo "style=\"border: solid 1px #e4e4e4; padding:10px; margin-bottom:30px;\""; echo">";
	?>
							
<script type="text/javascript">
function myPopup3<? echo $user_fc_id; ?>() {
window.open( "mailer.php?id=<? echo $user_fc_id; ?>", "myWindow", "status = 1, height = 300, width = 600, resizable = 0" )
}
</script>
<?php
	echo "<a name=\"fr$id\"></a>"; 
	if ($subdomena == 'tak') { echo "<a title=\"Pokaż szczegóły {$firma}\"  href=\"firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html\">"; } 
	echo "<span class=\"tytul_newsa\">$firma</span>";
	if ($subdomena == 'tak') { echo "</a>"; } 
	
	$miasto_do_adres = $row2['miasto'];
	$miasto_do_adres = przyjazny_link($miasto_do_adres);

	$ulica_do_adres = $row2['ulica'];
	$ulica_do_adres = przyjazny_link($ulica_do_adres);

							
    $firmId = $row2['user_id'];
    $firmaMiasto = $row2['najbl_miasto'];
    
    $query244 = "SELECT * FROM portal_miasta WHERE miasto = '$firmaMiasto'";
    $result244 = mysql_query ($query244);
    while ($row244 = mysql_fetch_array ($result244)) { $id_miasto_wpisu = $row244['miasto_id']; }
    
    $parent0=$_GET['parent0'];
    $parent1=$_GET['parent1'];
    
    $query_category = "SELECT * FROM firma_treeplacement_adv  WHERE user_id = '$firmId' LIMIT 1";
    $result_category = mysql_query ($query_category);
    
    while ($row_category = mysql_fetch_array ($result_category) ) {
        $IdParent0 = $row_category['parent0'];
 
        }

  echo"<p><a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;min=1&amp;max=10&amp;lokacja={$row2['woj_id']}&amp; ;#cattree\" style='color:#a2a2a2'>";
if (empty($parent1)) getTitleCategory($parent0);   
else getTitleCategoryBig($parent1); 
     
$wojewodztwo2 = $row2['woj_id'];
if ($wojewodztwo2 == 1)  echo' dolnośląskie';
if ($wojewodztwo2 == 2)  echo' kujawsko-pomorskie';
if ($wojewodztwo2 == 3) echo' lubelskie';
if ($wojewodztwo2 == 4) echo' lubuskie';
if ($wojewodztwo2 == 5) echo' łódzkie';
if ($wojewodztwo2 == 6) echo' małopolskie';
if ($wojewodztwo2 == 7) echo' mazowieckie';
if ($wojewodztwo2 == 8) echo' opolskie';
if ($wojewodztwo2 == 9) echo' podkarpackie';
if ($wojewodztwo2 == 10) echo' podlaskie';
if ($wojewodztwo2 == 11) echo' pomorskie';
if ($wojewodztwo2 == 12) echo' śląskie';
if ($wojewodztwo2 == 13) echo' świętokrzyskie';
if ($wojewodztwo2 == 14) echo' warmińsko-mazurskie';
if ($wojewodztwo2 == 15) echo' wielkopolskie';
if ($wojewodztwo2 == 16) echo' zachodniopomorskie';
echo "</a> / <a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=0&amp;parent3=0&amp;parent4=0&amp;c=all&amp;min=1&amp;max=10&amp;lokacja={$row2['woj_id']}&amp; ;$id_miasto_wpisu#cattree\" style='color:#a2a2a2'>";
if (empty($parent1)) getTitleCategory($parent0);   
else getTitleCategoryBig($parent1); 
echo " {$row2['najbl_miasto']}</a></p>";

if ($wizytowka != ''&& $logo == 'tak') {
	$rozmiar_zdjecia = getimagesize("../upload/firma/$user_fc_id/details/{$row2['wizytowka']}");
	if ($rozmiar_zdjecia[1] > 180 ) $zmniejsz_zdjecie = " style='height:180px;'";
	else $zmniejsz_zdjecie = "";               


	if ($subdomena == 'tak') {  echo"<p style='float:left; border:1px solid #dadada; margin-right:25px;'><a href='firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html'>"; }
	echo "<img src=\"/upload/firma/$user_fc_id/details/{$row2['wizytowka']}\" alt=\"{$firma} [ {$user_log} ] - ";
	if (empty($parent1)) getTitleCategory($parent0); else getTitleCategoryBig($parent1); 
	echo "\" class=\"news_img\"".$zmniejsz_zdjecie."/>"; if ($subdomena == 'tak') {  echo"</a>"; }	
	echo'</p>';
} 

$query66666 = "SELECT * FROM firma_rabaty WHERE user_id = '$user_fc_id'";
$result66666 = mysql_query ($query66666);
$row66666 = mysql_fetch_array($result66666);
$rabacik = $row66666['tytul'];
if($rabacik){
echo'<div style="position:absolute; background: url(images/katalog_rabat_tlo.png) no-repeat top center; width:110px; height:110px; margin-left:480px; margin-top:-10px;">
<a class="poplight" rel="rabat_'.$user_log.'" href="#?w=400" style="display:block; width:100px; height:100px;"></a>
</div>';

echo'<div id="rabat_'.$user_log.'" class="popup_block rec" style="display: none;">
<a class="close" href="#" onClick="$(\'#rabat_'.$user_log.'\').fadeOut(); return false;"><img class="btn_close" title="Close" src="images/zamknij.png" alt="Close"></a>
'.$rabacik.'
</div>';

}

echo'<table>
	<tr>
		<td class="wizytowka_caption">adres:</td>
		<td class="wizytowka_value">';
			if (!empty($row2['ulica'])) echo "ul. ";
			echo "{$row2['ulica']} {$row2['nrdomu']}";
		echo'</td>
	</tr>
	<tr>
		<td class="wizytowka_caption">miasto:</td>
		<td class="wizytowka_value">';
			echo"{$row2['kod']} {$row2['miasto']}"; 
		echo'</td>
	</tr>
	<tr>
		<td class="wizytowka_caption">WWW:</td>
		<td class="wizytowka_value">';
			if ($row2['www'] != '' && $www == 'tak') {
				$xtr = $row2['www'];
				if (strlen($xtr) > 32) $xtr = "przejdź na WWW";
				echo"<a href=\"http://{$row2['www']}\" onclick=\"return clk(".$user_fc_id.")\" target=\"_blank\" class=\"firma_link\">$xtr</a>";
			}
		echo'</td>
	</tr>
	</table>';
	
echo'<br><br><table style="float:left;'; if($skypegg == 'tak')echo'border-right: solid 2px '; echo'#e4e4e4; width:180px;">
	<tr>';
		if($row2['telefon']){
			echo'<td class="wizytowka_caption">telefon:</td>
			<td class="wizytowka_value">';
				echo$row2['telefon'];
			echo'</td>';
		}
	echo'</tr>
	<tr>';
		if($row2['fax']){
		echo'<td class="wizytowka_caption">faks:</td>
		<td class="wizytowka_value">';
			echo$row2['fax'];
		echo'</td>';
		}
	echo'</tr>
	<tr>';
			if ($row2['email'] != ''  && $row2['emwid'] == 'tak' && $email == 'tak') { 
				echo'<td class="wizytowka_caption">e-mail:</td>
				<td class="wizytowka_value">';
					
						echo'<a href="';
						if ($subdomena == 'tak' && $email == 'tak') {
							echo "firma,".przyjazny_link($firma).",".przyjazny_link($row2['miasto']).",".$row2['user_id'].".html/index.php?p=kontakt\" class=\"firma_link\"";
						} 
						else {
							echo "#mr$id\" onclick=\"myPopup3".$user_fc_id."()\"  class=\"firma_link\"";
						}
						echo ">Napisz do nas!</a></td>
						</tr>";
					
				echo'</td>';
			
			}
	echo'</tr>
	</table>';
if($skypegg == 'tak'){
	echo'<table style="float:left; width:175px; margin-left:5px;">
		<tr>';
			if ($row2['skype'] != '' && $skypegg == 'tak') {
				echo '<td class="wizytowka_caption">Skype:</td>
				<td class="wizytowka_value">';
									
					echo"<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
					<a href=\"skype:{$row2['skype']}?call\"><img src=\"http://mystatus.skype.com/smallclassic/{$row2['skype']}\" style=\"border: none;\" alt=\"Skype MeT!\" align=\"absmiddle\"/></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
				echo'</td>';
			}
		echo'</tr>
		<tr>';
			if ($row2['gg'] != '' && $skypegg == 'tak') {
				echo'<td class="wizytowka_caption">GG</td>
				<td class="wizytowka_value">';
					 
					echo "<font class=\"firma_bold\"><a href=\"gg:{$row2['gg']}\"><img src=\"http://status.gadu-gadu.pl/users/status.asp?id={$row2['gg']}&amp;styl=3\" border=\"0\"  align=\"absmiddle\"/></a><br />"; 
					 
				echo'</td>';
			}
			
		echo'</tr>
		</table>';
}
echo'<div style="clear:both;"></div>';
		
?>
<script type="text/javascript">
function myPopup2<? echo $user_fc_id; ?>() {
window.open( "favorites.php?id=<? echo $user_fc_id; ?>", "myWindow", 
"status = 1, height = 150, width = 300, resizable = 0, top = 250, left = 450" )
}
</script>
<?php
	$row2['id'] = $user_fc_id;
	if($opis == 'tak'){
		echo'<div style="background: #f6f6f6 url(images/katalog_szczegoly_tlo.png) no-repeat top center; width:603px; height:33px; margin: 15px 0 -10px -10px; padding-top:6px;">
		<p>
		<a href="firma,'.$user_log.'/index.php?p=galeria#subcontent" style="margin-left:40px; color:#a2a2a2; text-decoration:underline;">zobacz zdjęcia</a>
		<a href="firma,'.$user_log.'/index.php?p=opinie#subcontent" style="margin-left:65px; color:#a2a2a2; text-decoration:underline;">zobacz opinie</a>
		<a href="#?w=400&lat=&lng=&id='.$row2['id'].'&ulica='.$row2['ulica'].' '.$row2['nrdomu'].'&poczta='.$row2['kod'].'&miasto='.$row2['miasto'].'&marker=FE7569" class="poplight" rel="mapa_popup_'.$row2['id'].'" style="margin-left:55px; color:#a2a2a2; text-decoration:underline;">lokalizacja na mapie</a>
		<a href="firma,'.$user_log.'.html" style="margin-left:65px; color:#a2a2a2; text-decoration:underline;">zobacz więcej</a>
		</p>
		</div>';
		
		echo'<div id="mapa_popup_'.$row2['id'].'" class="popup_block" style="display: none">
			<a class="close" href="#" onClick="$(\'#mapa_popup_'.$row2['id'].'\').fadeOut(); return false;"><img class="btn_close" title="Close" src="images/zamknij.png" alt="Close"></a>
			<div><p style="padding-bottom: 10px; text-align: left;"><b>Lokalizacja na mapie: '.$firma.'</b></p></div>
			<div id="map_canvas_'.$row2['id'].'" style="width: 400px; height: 400px;"></div>							
		</div>';
	}
	echo"</div>";
	
	// echo '									
	// <script type="text/javascript"><!--
	// google_ad_client = "ca-pub-2710687790885824";
	// /* W katalogi firm pomiedzy firmami */
	// google_ad_slot = "5350516632";
	// google_ad_width = 468;
	// google_ad_height = 60;
	// -->
	// </script>
	// <script type="text/javascript"
	// src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
	// </script>	
	// ';

								
								
	}
}}}
 $lp++;
//echo $lp;

 }	}
}

$lp2 = 1;		
$min_x = 1;	
	$xfq = 0;
	$query7 = "SELECT abonament_id, priorytet FROM portal_abonamenty ORDER BY priorytet DESC";
$result7 = mysql_query($query7);
	 while ($row7 = mysql_fetch_array ($result7) ) {      
	$pri = $row7['abonament_id'];
		
	if ($parent0 == 0 && $parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent1 == 0 && $parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent2 == 0 && $parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent3 == 0  && $parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
elseif ($parent4 == 0)   
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
else	
$query2 = "SELECT DISTINCT f.user_id FROM firma_treeplacement_adv as f, firma_details as u, firma_platnosci as p where f.parent0 = '$parent0' AND f.parent1 = '$parent1' AND f.parent2 = '$parent2' AND f.parent3 = '$parent3'AND f.parent4 = '$parent4' AND f.abonament_id = '$pri' AND f.user_id = u.user_id AND f.user_id = p.user_id AND (p.aktywne = '1' OR p.aktywne = '2') $special_war ORDER BY u.nazwa ASC";
	//echo $query2.'<br/>';
	    $result2 = mysql_query ($query2);
	$xcq = mysql_affected_rows();
	//echo ' - '.$xcq.'<br/>';
	$xfq = $xfq + $xcq;
   }
	// echo $xfq;
	
	
  $temp = explode(";", $_GET['lokacja']);
  $id_miasto_current = $temp[1];
  $query2 = "SELECT * FROM portal_miasta WHERE miasto_id = '$id_miasto_current'";
  $result2 = mysql_query ($query2);
  while ($row2 = mysql_fetch_array ($result2)) { $nazwa_miasto_current = $row2['miasto']; }
  $wns = 10;
  $ilosc = $xfq;
  $ilosc_stron = ceil($ilosc/$wns);
  $str = $max/10;
  

  if($ilosc > $wns){	
		$min_x = 10*($str-2)+1;
		$max_x = 10*($str-1);
		echo '<div><p style="text-align: center; padding-left:25px; padding-right: 20px;">';
		// if($str>1) echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;wojewodztwo=$wojewodztwo&amp;miasto=$id_miasto_current#cattree\" title=\"";
		if($str>1){ echo "<a href=\"katalog,";if (empty($parent1) && !empty($parent0)) {echo przyjazny_link(getTitleCategory2($parent0)); }  
	elseif (!empty($parent1) && empty($parent2)) {echo przyjazny_link(getTitleCategoryBig2($parent1));} 
	elseif (!empty($parent2) && empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent2));}
	elseif (!empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent3));}echo",$parent0,$parent1,$parent2,$parent3,$parent4,all,$min_x,$max_x,$wojewodztwo;$id_miasto_current.html#cattree\" title=\"";
	
	if (empty($parent1) && !empty($parent0)) {getTitleCategory($parent0); }  
	elseif (!empty($parent1) && empty($parent2)) {getTitleCategoryBig($parent1);} 
	elseif (!empty($parent2) && empty($parent3)) {getTitleCategoryBig($parent2);}
	elseif (!empty($parent3)) {echo getTitleCategoryBig($parent3);}

	 if ( !empty($nazwa_miasto_current) ) {
	 echo ' '.$nazwa_miasto_current; 
	 }
	if ($wojewodztwo == 1) echo' (dolnośląskie)';
	if ($wojewodztwo == 2) echo' (kujawsko-pomorskie)';
	if ($wojewodztwo == 3) echo' (lubelskie)';
	if ($wojewodztwo == 4) echo' (lubuskie)';
	if ($wojewodztwo == 5) echo' (łódzkie)';
	if ($wojewodztwo == 6) echo' (małopolskie)';
	if ($wojewodztwo == 7) echo' (mazowieckie)';
	if ($wojewodztwo == 8) echo' (opolskie)';
	if ($wojewodztwo == 9) echo' (podkarpackie)';
	if ($wojewodztwo == 10) echo' (podlaskie)';
	if ($wojewodztwo == 11) echo' (pomorskie)';
	if ($wojewodztwo == 12) echo' (śląskie)';
	if ($wojewodztwo == 13) echo' (świętokrzyskie)';
	if ($wojewodztwo == 14) echo' (warmińsko-mazurskie)';
	if ($wojewodztwo == 15) echo' (wielkopolskie)';
	if ($wojewodztwo == 16) echo' (zachodniopomorskie)';echo"\" class='stronicowanie'>&laquo;</a>";
	}
		
		for($i=1;$i<=$ilosc_stron;$i++){
                    if($ilosc_stron > 11)
                    {
			if($str < $ilosc_stron-6 && $i == $ilosc_stron-2) 
                            echo ' ... &nbsp;&nbsp;';
                        if($str > 7 && $i == 4) 
                            echo ' ... &nbsp;&nbsp;';
                    }
                        if(($i >= 1 && $i <= 3) || ($i >= $ilosc_stron-2 && $i <= $ilosc_stron) || ($i >= $str-3 && $i <= $str+3) || ($i <= 7 && $str < 3))
                            {
				if($i == $str){
                                    $min_x = ($i*10)-9;
                                    $max_x = $i*10;
					// echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;wojewodztwo=$wojewodztwo&amp;miasto=$id_miasto_current#cattree\" title=\"";
					echo "<a href=\"katalog,";if (empty($parent1) && !empty($parent0)) {echo przyjazny_link(getTitleCategory2($parent0)); }  
	elseif (!empty($parent1) && empty($parent2)) {echo przyjazny_link(getTitleCategoryBig2($parent1));} 
	elseif (!empty($parent2) && empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent2));}
	elseif (!empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent3));}echo",$parent0,$parent1,$parent2,$parent3,$parent4,all,$min_x,$max_x,$wojewodztwo;$id_miasto_current.html#cattree\" title=\"";
					if (empty($parent1) && !empty($parent0)) {getTitleCategory($parent0); }  
	elseif (!empty($parent1) && empty($parent2)) {getTitleCategoryBig($parent1);} 
	elseif (!empty($parent2) && empty($parent3)) {getTitleCategoryBig($parent2);}
	elseif (!empty($parent3)) {echo getTitleCategoryBig($parent3);}

	 if ( !empty($nazwa_miasto_current) ) {
	 echo ' '.$nazwa_miasto_current; 
	 }
	if ($wojewodztwo == 1) echo' (dolnośląskie)';
	if ($wojewodztwo == 2) echo' (kujawsko-pomorskie)';
	if ($wojewodztwo == 3) echo' (lubelskie)';
	if ($wojewodztwo == 4) echo' (lubuskie)';
	if ($wojewodztwo == 5) echo' (łódzkie)';
	if ($wojewodztwo == 6) echo' (małopolskie)';
	if ($wojewodztwo == 7) echo' (mazowieckie)';
	if ($wojewodztwo == 8) echo' (opolskie)';
	if ($wojewodztwo == 9) echo' (podkarpackie)';
	if ($wojewodztwo == 10) echo' (podlaskie)';
	if ($wojewodztwo == 11) echo' (pomorskie)';
	if ($wojewodztwo == 12) echo' (śląskie)';
	if ($wojewodztwo == 13) echo' (świętokrzyskie)';
	if ($wojewodztwo == 14) echo' (warmińsko-mazurskie)';
	if ($wojewodztwo == 15) echo' (wielkopolskie)';
	if ($wojewodztwo == 16) echo' (zachodniopomorskie)';echo"\" class='stronicowanie strona'>".($i)."</a>";
				}
				else{
					$min_x = ($i*10)-9;
					$max_x = $i*10;
					// echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;wojewodztwo=$wojewodztwo&amp;miasto=$id_miasto_current#cattree\" title=\"";
					echo "<a href=\"katalog,";if (empty($parent1) && !empty($parent0)) {echo przyjazny_link(getTitleCategory2($parent0)); }  
	elseif (!empty($parent1) && empty($parent2)) {echo przyjazny_link(getTitleCategoryBig2($parent1));} 
	elseif (!empty($parent2) && empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent2));}
	elseif (!empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent3));}echo",$parent0,$parent1,$parent2,$parent3,$parent4,all,$min_x,$max_x,$wojewodztwo;$id_miasto_current.html#cattree\" title=\"";
					if (empty($parent1) && !empty($parent0)) {getTitleCategory($parent0); }  
	elseif (!empty($parent1) && empty($parent2)) {getTitleCategoryBig($parent1);} 
	elseif (!empty($parent2) && empty($parent3)) {getTitleCategoryBig($parent2);}
	elseif (!empty($parent3)) {echo getTitleCategoryBig($parent3);}

	 if ( !empty($nazwa_miasto_current) ) {
	 echo ' '.$nazwa_miasto_current; 
	 }
	if ($wojewodztwo == 1) echo' (dolnośląskie)';
	if ($wojewodztwo == 2) echo' (kujawsko-pomorskie)';
	if ($wojewodztwo == 3) echo' (lubelskie)';
	if ($wojewodztwo == 4) echo' (lubuskie)';
	if ($wojewodztwo == 5) echo' (łódzkie)';
	if ($wojewodztwo == 6) echo' (małopolskie)';
	if ($wojewodztwo == 7) echo' (mazowieckie)';
	if ($wojewodztwo == 8) echo' (opolskie)';
	if ($wojewodztwo == 9) echo' (podkarpackie)';
	if ($wojewodztwo == 10) echo' (podlaskie)';
	if ($wojewodztwo == 11) echo' (pomorskie)';
	if ($wojewodztwo == 12) echo' (śląskie)';
	if ($wojewodztwo == 13) echo' (świętokrzyskie)';
	if ($wojewodztwo == 14) echo' (warmińsko-mazurskie)';
	if ($wojewodztwo == 15) echo' (wielkopolskie)';
	if ($wojewodztwo == 16) echo' (zachodniopomorskie)';echo"\" class='stronicowanie'>".$i."</a>";
				}
			}				
		}
		$min_x = 10*$str+1;
		$max_x = 10*($str+1);
        if($i-1 != $str)
        {
		// echo "<a href=\"katalog_firm.php?parent0=$parent0&amp;parent1=$parent1&amp;parent2=$parent2&amp;parent3=$parent3&amp;parent4=$parent4&amp;c=all&amp;min=$min_x&amp;max=$max_x&amp;wojewodztwo=$wojewodztwo&amp;miasto=$id_miasto_current#cattree\" title=\"";
		echo "<a href=\"katalog,";if (empty($parent1) && !empty($parent0)) {echo przyjazny_link(getTitleCategory2($parent0)); }  
	elseif (!empty($parent1) && empty($parent2)) {echo przyjazny_link(getTitleCategoryBig2($parent1));} 
	elseif (!empty($parent2) && empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent2));}
	elseif (!empty($parent3)) {echo przyjazny_link(getTitleCategoryBig2($parent3));}echo",$parent0,$parent1,$parent2,$parent3,$parent4,all,$min_x,$max_x,$wojewodztwo;$id_miasto_current.html#cattree\" title=\"";
		if (empty($parent1) && !empty($parent0)) {getTitleCategory($parent0); }  
	elseif (!empty($parent1) && empty($parent2)) {getTitleCategoryBig($parent1);} 
	elseif (!empty($parent2) && empty($parent3)) {getTitleCategoryBig($parent2);}
	elseif (!empty($parent3)) {echo getTitleCategoryBig($parent3);}

	 if ( !empty($nazwa_miasto_current) ) {
	 echo ' '.$nazwa_miasto_current; 
	 }
	if ($wojewodztwo == 1) echo' (dolnośląskie)';
	if ($wojewodztwo == 2) echo' (kujawsko-pomorskie)';
	if ($wojewodztwo == 3) echo' (lubelskie)';
	if ($wojewodztwo == 4) echo' (lubuskie)';
	if ($wojewodztwo == 5) echo' (łódzkie)';
	if ($wojewodztwo == 6) echo' (małopolskie)';
	if ($wojewodztwo == 7) echo' (mazowieckie)';
	if ($wojewodztwo == 8) echo' (opolskie)';
	if ($wojewodztwo == 9) echo' (podkarpackie)';
	if ($wojewodztwo == 10) echo' (podlaskie)';
	if ($wojewodztwo == 11) echo' (pomorskie)';
	if ($wojewodztwo == 12) echo' (śląskie)';
	if ($wojewodztwo == 13) echo' (świętokrzyskie)';
	if ($wojewodztwo == 14) echo' (warmińsko-mazurskie)';
	if ($wojewodztwo == 15) echo' (wielkopolskie)';
	if ($wojewodztwo == 16) echo' (zachodniopomorskie)';echo"\" class='stronicowanie'>&raquo;</a>";
        }
            echo'</div>';
	}
  
}














// Paginacja strony wyciągające elementy z danej tablicy
// [tablica z bazy], [nazwa pliku z paginacją], [Wyników Na Stronę], [warnki zapytania SQL], [dodatkowe zmienne GET]
function paginacja($table, $name, $wns, $whe, $att) {
        $wynik = "<div class=\"center\">";		
        
        $query = "SELECT COUNT(*) FROM ".$table." WHERE 1=1 ".$whe;
        $result = mysql_query ($query);
        $row = mysql_fetch_array ($result);
            
        if(!$_GET['page'])
            $page = 1;
        else
            $page = $_GET['page'];
        
        $lp = ceil($row[0] / $wns);
        
        if($page > 1)
        {
            $wynik .= "<a class=\"stronicowanie\" href=\"".$name;
            if($page != 2)
                $wynik .= "?page=".($page-1);
            $wynik .= $att."\">&laquo;</a>";
        }
        
        
        for($i = 1; $i <= $lp; $i++)
        {
                if($i == 1)
                    $p = '';
                else
                    $p = '?page='.$i;
                
                if($lp > 11)
                {
                    if($page < $lp-6 && $i == $lp-2) 
                        $wynik .= ' ... &nbsp;&nbsp;';
                    if($page > 7 && $i == 4) 
                        $wynik .= ' ... &nbsp;&nbsp;';
                }
                
                if($i < 4 || $i > $lp-3 || ($i > $page-4 && $i < $page+4)) {
                
                $wynik .= "<=\"stronicowanie";
                
                if($page == $i)
                    $wynik .= " strona\" href=\"".$name.$p.$att."#\"";
                else
                    $wynik .= "\" href=\"".$name.$p.$att."\"";
            
                $wynik .= ">$i</a>";
                
                }
        }
        
        if($page < $lp)
            $wynik .= "<a class=\"stronicowanie\" href=\"".$name."?page=".($page+1).$att."\">&raquo;</a>";
        
        $wynik .= "</a>";
        
        return $wynik;
}


?>
